Commit f76fa00e authored by DrKLO's avatar DrKLO

More Android L design

parent 934408c7
......@@ -17,7 +17,7 @@ tasks.withType(JavaCompile) {
}
dependencies {
compile 'com.android.support:support-v4:20.0.+'
compile 'com.android.support:support-v4:21.0.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.2'
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
......
......@@ -17,8 +17,10 @@ import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.util.StateSet;
import android.view.Display;
import android.view.Surface;
import android.view.View;
......@@ -491,4 +493,23 @@ public class AndroidUtilities {
}
}
}
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable = null;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.NOTHING);
drawable.jumpToCurrentState();
}
}
}
}
......@@ -54,6 +54,11 @@ public class ContactsController {
private String inviteText;
private boolean updatingInviteText = false;
private int loadingDeleteInfo = 0;
private int deleteAccountTTL;
private int loadingLastSeenInfo = 0;
private ArrayList<TLRPC.PrivacyRule> privacyRules = null;
public static class Contact {
public int id;
public ArrayList<String> phones = new ArrayList<String>();
......@@ -119,6 +124,10 @@ public class ContactsController {
contactsLoaded = false;
contactsBookLoaded = false;
lastContactsVersions = "";
loadingDeleteInfo = 0;
deleteAccountTTL = 0;
loadingLastSeenInfo = 0;
privacyRules = null;
}
public void checkInviteText() {
......@@ -1568,6 +1577,81 @@ public class ContactsController {
}, true, RPCRequest.RPCRequestClassGeneric);
}
public void loadPrivacySettings() {
if (loadingDeleteInfo == 0) {
loadingDeleteInfo = 1;
TLRPC.TL_account_getAccountTTL req = new TLRPC.TL_account_getAccountTTL();
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (error == null) {
TLRPC.TL_accountDaysTTL ttl = (TLRPC.TL_accountDaysTTL) response;
deleteAccountTTL = ttl.days;
loadingDeleteInfo = 2;
} else {
loadingDeleteInfo = 0;
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.privacyRulesUpdated);
}
});
}
});
}
if (loadingLastSeenInfo == 0) {
loadingLastSeenInfo = 1;
TLRPC.TL_account_getPrivacy req = new TLRPC.TL_account_getPrivacy();
req.key = new TLRPC.TL_inputPrivacyKeyStatusTimestamp();
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (error == null) {
TLRPC.TL_account_privacyRules rules = (TLRPC.TL_account_privacyRules) response;
MessagesController.getInstance().putUsers(rules.users, false);
privacyRules = rules.rules;
loadingLastSeenInfo = 2;
} else {
loadingLastSeenInfo = 0;
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.privacyRulesUpdated);
}
});
}
});
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.privacyRulesUpdated);
}
public void setDeleteAccountTTL(int ttl) {
deleteAccountTTL = ttl;
}
public int getDeleteAccountTTL() {
return deleteAccountTTL;
}
public boolean getLoadingDeleteInfo() {
return loadingDeleteInfo != 2;
}
public boolean getLoadingLastSeenInfo() {
return loadingLastSeenInfo != 2;
}
public ArrayList<TLRPC.PrivacyRule> getPrivacyRules() {
return privacyRules;
}
public void setPrivacyRules(ArrayList<TLRPC.PrivacyRule> rules) {
privacyRules = rules;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.privacyRulesUpdated);
}
public static String formatName(String firstName, String lastName) {
String result = null;
if (LocaleController.nameDisplayOrder == 1) {
......
......@@ -427,4 +427,8 @@ public class ImageReceiver {
bitmapRect = null;
}
}
public int getRoundRadius() {
return roundRadius;
}
}
......@@ -783,7 +783,7 @@ public class LocaleController {
public static String formatUserStatus(TLRPC.User user) {
if (user == null || user.status == null || user.status.expires == 0 || user instanceof TLRPC.TL_userDeleted || user instanceof TLRPC.TL_userEmpty) {
return getString("Offline", R.string.Offline);
return getString("ALongTimeAgo", R.string.ALongTimeAgo);
} else {
int currentTime = ConnectionsManager.getInstance().getCurrentTime();
if (user.status.expires > currentTime) {
......@@ -791,6 +791,12 @@ public class LocaleController {
} else {
if (user.status.expires == -1) {
return getString("Invisible", R.string.Invisible);
} else if (user.status.expires == -100) {
return getString("Lately", R.string.Lately);
} else if (user.status.expires == -101) {
return getString("WithinAWeek", R.string.WithinAWeek);
} else if (user.status.expires == -102) {
return getString("WithinAMonth", R.string.WithinAMonth);
} else {
return formatDateOnline(user.status.expires);
}
......
......@@ -60,7 +60,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public boolean loadingBlockedUsers = false;
public ArrayList<Integer> blockedUsers = new ArrayList<Integer>();
public HashMap<Integer, TLRPC.User> hidenAddToContacts = new HashMap<Integer, TLRPC.User>();
private HashMap<Integer, TLRPC.EncryptedChat> acceptingChats = new HashMap<Integer, TLRPC.EncryptedChat>();
private ArrayList<TLRPC.Updates> updatesQueue = new ArrayList<TLRPC.Updates>();
private ArrayList<Long> pendingEncMessagesToDelete = new ArrayList<Long>();
......@@ -317,7 +316,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
printingStrings.clear();
totalDialogsCount = 0;
lastPrintingStringCount = 0;
hidenAddToContacts.clear();
updatesQueue.clear();
pendingEncMessagesToDelete.clear();
delayedEncryptedChatUpdates.clear();
......@@ -391,7 +389,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (user == null) {
return false;
}
fromCache = fromCache && user.id / 1000 != 333;
fromCache = fromCache && user.id / 1000 != 333 && user.id != 777000;
TLRPC.User oldUser = users.get(user.id);
if (!fromCache) {
users.put(user.id, user);
......@@ -758,6 +756,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (user != null) {
user.photo = UserConfig.getCurrentUser().photo;
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
......@@ -1379,7 +1378,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (!isCache) {
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
}
if (lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 3)) {
if (lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 2 || load_type == 3)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
......@@ -3242,6 +3241,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
arr.add(obj);
pushMessages.add(obj);
} else if (update instanceof TLRPC.TL_updatePrivacy) {
updatesOnMainThread.add(update);
}
}
if (!messages.isEmpty()) {
......@@ -3299,7 +3300,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.User toDbUser = new TLRPC.User();
toDbUser.id = update.user_id;
TLRPC.User currentUser = getUser(update.user_id);
if (update instanceof TLRPC.TL_updateUserStatus) {
if (update instanceof TLRPC.TL_updatePrivacy) {
if (update.key instanceof TLRPC.TL_privacyKeyStatusTimestamp) {
ContactsController.getInstance().setPrivacyRules(update.rules);
}
} else if (update instanceof TLRPC.TL_updateUserStatus) {
if (update.status instanceof TLRPC.TL_userStatusRecently) {
update.status.expires = -100;
} else if (update.status instanceof TLRPC.TL_userStatusLastWeek) {
update.status.expires = -101;
} else if (update.status instanceof TLRPC.TL_userStatusLastMonth) {
update.status.expires = -102;
}
if (currentUser != null) {
currentUser.id = update.user_id;
currentUser.status = update.status;
......
......@@ -41,6 +41,8 @@ public class NotificationCenter {
public static final int hideEmojiKeyboard = 30;
public static final int stopEncodingService = 31;
public static final int didCreatedNewDeleteTask = 32;
public static final int mainUserInfoChanged = 33;
public static final int privacyRulesUpdated = 34;
public static final int wallpapersDidLoaded = 171;
public static final int closeOtherAppActivities = 702;
......
......@@ -17,7 +17,6 @@ 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;
......@@ -38,8 +37,6 @@ public class ActionBar extends FrameLayout {
}
}
private static boolean withStatusBar = Build.VERSION.SDK_INT >= 21;
private FrameLayout titleFrameLayout;
private ImageView backButtonImageView;
private TextView titleTextView;
......@@ -47,6 +44,7 @@ public class ActionBar extends FrameLayout {
private ActionBarMenu menu;
private ActionBarMenu actionMode;
private View actionOverlay;
private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21;
protected boolean isSearchFieldVisible;
protected int itemsBackgroundResourceId;
......@@ -64,9 +62,6 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
if (withStatusBar) {
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
titleFrameLayout.setLayoutParams(layoutParams);
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
titleFrameLayout.setEnabled(false);
......@@ -162,8 +157,9 @@ public class ActionBar extends FrameLayout {
subTitleTextView.setLayoutParams(layoutParams);
}
ViewGroup.LayoutParams layoutParams1 = titleFrameLayout.getLayoutParams();
MarginLayoutParams layoutParams1 = (MarginLayoutParams) titleFrameLayout.getLayoutParams();
layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6));
layoutParams1.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
titleFrameLayout.setLayoutParams(layoutParams1);
}
......@@ -175,9 +171,7 @@ public class ActionBar extends FrameLayout {
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;
}
layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
menu.setLayoutParams(layoutParams);
menu.measure(width, height);
}
......@@ -330,9 +324,7 @@ public class ActionBar extends FrameLayout {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)view.getLayoutParams();
layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.height = LayoutParams.FILL_PARENT;
if (withStatusBar) {
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
view.setLayoutParams(layoutParams);
}
......@@ -343,13 +335,11 @@ public class ActionBar extends FrameLayout {
actionMode = new ActionBarMenu(getContext(), this);
actionMode.setBackgroundResource(R.drawable.editheader);
addView(actionMode);
actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0);
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;
......@@ -414,9 +404,7 @@ public class ActionBar extends FrameLayout {
positionMenu(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
positionTitle(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
positionBackOverlay(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
if (Build.VERSION.SDK_INT >= 21) {
actionBarHeight += AndroidUtilities.statusBarHeight;
}
actionBarHeight += occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(actionBarHeight + extraHeight, MeasureSpec.EXACTLY));
}
......@@ -495,14 +483,20 @@ public class ActionBar extends FrameLayout {
layoutParams.height = LayoutParams.MATCH_PARENT;
actionOverlay.setLayoutParams(layoutParams);
actionOverlay.measure(widthMeasureSpec, heightMeasureSpec);
if (withStatusBar) {
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + AndroidUtilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0));
actionOverlay.setLayoutParams(layoutParams);
}
}
public void setOccupyStatusBar(boolean value) {
occupyStatusBar = value;
}
public boolean getOccupyStatusBar() {
return occupyStatusBar;
}
public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId;
if (backButtonImageView != null) {
......
......@@ -56,14 +56,46 @@ public class ActionBarLayout extends FrameLayout {
setOrientation(VERTICAL);
}
/*@Override
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
int saveCount = canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight());
if (child instanceof ActionBar) {
return super.drawChild(canvas, child, drawingTime);
} else {
boolean wasActionBar = false;
int actionBarHeight = 0;
int childCount = getChildCount();
for (int a = 0; a < childCount; a++) {
View view = getChildAt(a);
if (view == child) {
continue;
}
if (view instanceof ActionBar) {
actionBarHeight = view.getMeasuredHeight();
wasActionBar = true;
break;
}
}
/*if (!wasActionBar) {
if (child instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) child;
childCount = viewGroup.getChildCount();
for (int a = 0; a < childCount; a++) {
View possibleActionBar = viewGroup.getChildAt(a);
if (possibleActionBar instanceof ActionBar) {
actionBarHeight = possibleActionBar.getMeasuredHeight();
break;
}
}
}
}*/
boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restoreToCount(saveCount);
if (actionBarHeight != 0 && headerShadowDrawable != null) {
headerShadowDrawable.setBounds(0, actionBarHeight, getMeasuredWidth(), actionBarHeight + headerShadowDrawable.getIntrinsicHeight());
headerShadowDrawable.draw(canvas);
}
return result;
}*/
}
}
}
private static Drawable headerShadowDrawable;
......@@ -79,21 +111,22 @@ public class ActionBarLayout extends FrameLayout {
public float innerTranslationX;
private boolean maybeStartTracking = false;
protected boolean startedTracking = false;
private boolean maybeStartTracking;
protected boolean startedTracking;
private int startedTrackingX;
private int startedTrackingY;
protected boolean animationInProgress = false;
private VelocityTracker velocityTracker = null;
private boolean beginTrackingSent = false;
private boolean transitionAnimationInProgress = false;
protected boolean animationInProgress;
private VelocityTracker velocityTracker;
private boolean beginTrackingSent;
private boolean transitionAnimationInProgress;
private long transitionAnimationStartTime;
private boolean inActionMode = false;
private boolean inActionMode;
private int startedTrackingPointerId;
private Runnable onCloseAnimationEndRunnable = null;
private Runnable onOpenAnimationEndRunnable = null;
private boolean useAlphaAnimations = false;
private Runnable onCloseAnimationEndRunnable;
private Runnable onOpenAnimationEndRunnable;
private boolean useAlphaAnimations;
private View backgroundView;
private boolean removeActionBarExtraHeight;
private ActionBarLayoutDelegate delegate = null;
protected Activity parentActivity = null;
......@@ -106,6 +139,7 @@ public class ActionBarLayout extends FrameLayout {
if (layerShadowDrawable == null) {
layerShadowDrawable = getResources().getDrawable(R.drawable.layer_shadow);
headerShadowDrawable = getResources().getDrawable(R.drawable.header_shadow);
scrimPaint = new Paint();
}
}
......@@ -113,7 +147,6 @@ public class ActionBarLayout extends FrameLayout {
public void init(ArrayList<BaseFragment> stack) {
fragmentsStack = stack;
containerViewBack = new LinearLayoutContainer(parentActivity);
//containerViewBack.setOrientation(LinearLayout.VERTICAL);
addView(containerViewBack);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
......@@ -122,7 +155,6 @@ public class ActionBarLayout extends FrameLayout {
containerViewBack.setLayoutParams(layoutParams);
containerView = new LinearLayoutContainer(parentActivity);
//containerView.setOrientation(LinearLayout.VERTICAL);
addView(containerView);
layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
......@@ -199,10 +231,10 @@ public class ActionBarLayout extends FrameLayout {
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
int width = getWidth();
int translationX = (int) innerTranslationX;
int clipLeft = 0;
int clipRight = width;
int width = getWidth() - getPaddingLeft() - getPaddingRight();
int translationX = (int) innerTranslationX + getPaddingRight();
int clipLeft = getPaddingLeft();
int clipRight = width + getPaddingLeft();
if (child == containerViewBack) {
clipRight = translationX;
......@@ -296,6 +328,9 @@ public class ActionBarLayout extends FrameLayout {
if (parent != null) {
parent.removeView(lastFragment.actionBar);
}
if (removeActionBarExtraHeight) {
lastFragment.actionBar.setOccupyStatusBar(false);
}
containerViewBack.addView(lastFragment.actionBar);
}
containerViewBack.addView(fragmentView);
......@@ -513,15 +548,15 @@ public class ActionBarLayout extends FrameLayout {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard);
}
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;
}
final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;
fragment.setParentLayout(this);
View fragmentView = fragment.createView(parentActivity.getLayoutInflater(), null);
if (fragment.needAddActionBar() && fragment.actionBar != null) {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
}
containerViewBack.addView(fragment.actionBar);
}
containerViewBack.addView(fragmentView);
......@@ -553,8 +588,6 @@ public class ActionBarLayout extends FrameLayout {
if (needAnimation) {
if (useAlphaAnimations && fragmentsStack.size() == 1) {
presentFragmentInternalRemoveOld(removeLast, currentFragment);
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
animatorSet.playTogether();
ArrayList<Object> animators = new ArrayList<Object>();
animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f));
......@@ -639,9 +672,6 @@ public class ActionBarLayout extends FrameLayout {
AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
}
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);
BaseFragment previousFragment = null;
if (fragmentsStack.size() > 1) {
......@@ -657,6 +687,9 @@ public class ActionBarLayout extends FrameLayout {
previousFragment.setParentLayout(this);
View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null);
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
containerView.addView(previousFragment.actionBar);
}
containerView.addView(fragmentView);
......@@ -700,7 +733,7 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.start();
}
} else {
if (needAnimation && useAlphaAnimations) {
if (useAlphaAnimations) {
transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true;
......@@ -712,6 +745,9 @@ public class ActionBarLayout extends FrameLayout {
if (backgroundView != null) {
backgroundView.setVisibility(GONE);
}
if (drawerLayoutContainer != null) {
drawerLayoutContainer.setAllowOpenDrawer(true);
}
}
};
......@@ -750,6 +786,9 @@ public class ActionBarLayout extends FrameLayout {
previousFragment.setParentLayout(this);
View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null);
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
containerView.addView(previousFragment.actionBar);
}
containerView.addView(fragmentView);
......@@ -891,4 +930,8 @@ public class ActionBarLayout extends FrameLayout {
public DrawerLayoutContainer getDrawerLayoutContainer() {
return drawerLayoutContainer;
}
public void setRemoveActionBarExtraHeight(boolean value) {
removeActionBarExtraHeight = value;
}
}
......@@ -9,6 +9,7 @@
package org.telegram.ui.ActionBar;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
......@@ -58,19 +59,31 @@ public class ActionBarMenu extends LinearLayout {
return view;
}
public ActionBarMenuItem addItem(int id, Drawable drawable) {
return addItem(id, 0, parentActionBar.itemsBackgroundResourceId, drawable, AndroidUtilities.dp(48));
}
public ActionBarMenuItem addItem(int id, int icon) {
return addItem(id, icon, parentActionBar.itemsBackgroundResourceId);
}
public ActionBarMenuItem addItem(int id, int icon, int backgroundResource) {
return addItem(id, icon, parentActionBar.itemsBackgroundResourceId, AndroidUtilities.dp(48));
return addItem(id, icon, backgroundResource, null, AndroidUtilities.dp(48));
}
public ActionBarMenuItem addItemWithWidth(int id, int icon, int width) {
return addItem(id, icon, parentActionBar.itemsBackgroundResourceId, null, width);
}
public ActionBarMenuItem addItem(int id, int icon, int backgroundResource, int width) {
public ActionBarMenuItem addItem(int id, int icon, int backgroundResource, Drawable drawable, int width) {
ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource);
menuItem.setTag(id);
menuItem.setScaleType(ImageView.ScaleType.CENTER);
if (drawable != null) {
menuItem.setImageDrawable(drawable);
} else {
menuItem.setImageResource(icon);
}
addView(menuItem);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams();
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
......
......@@ -54,7 +54,7 @@ public class ActionBarMenuItem extends ImageView {
private View selectedMenuView;
private Runnable showMenuRunnable;
private boolean showFromBottom;
private int height;
private int menuHeight = AndroidUtilities.dp(16);
public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) {
super(context);
......@@ -135,7 +135,7 @@ public class ActionBarMenuItem extends ImageView {
showFromBottom = value;
}
public void addSubItem(int id, String text, int icon) {
public TextView addSubItem(int id, String text, int icon) {
if (popupLayout == null) {
rect = new Rect();
location = new int[2];
......@@ -166,7 +166,7 @@ public class ActionBarMenuItem extends ImageView {
});
}
TextView textView = new TextView(getContext());
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setBackgroundResource(R.drawable.list_selector);
if (!LocaleController.isRTL) {
textView.setGravity(Gravity.CENTER_VERTICAL);
......@@ -203,6 +203,8 @@ public class ActionBarMenuItem extends ImageView {
}
}
});
menuHeight += layoutParams.height;
return textView;
}
public boolean hasSubMenu() {
......@@ -245,25 +247,31 @@ public class ActionBarMenuItem extends ImageView {
popupWindow.setFocusable(true);
if (popupLayout.getMeasuredWidth() == 0) {
if (showFromBottom) {
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -popupLayout.getMeasuredHeight() + AndroidUtilities.dp(12));
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -popupLayout.getMeasuredHeight() + AndroidUtilities.dp(12), -1, -1);
height = popupLayout.getMeasuredHeight();
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY());
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY(), -1, -1);
} else {
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 {
if (showFromBottom) {
if (height == 0) {
height = popupLayout.getMeasuredHeight();
}
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -height + AndroidUtilities.dp(12));
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY());
} else {
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight());
}
}
}
private int getBottomOffsetY() {
getLocationOnScreen(location);
int diff = location[1] - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + getMeasuredHeight() - menuHeight;
int y = AndroidUtilities.dp(8) - menuHeight;
if (diff < 0) {
y -= diff;
}
return y;
}
public boolean toggleSearch() {
if (searchField == null) {
return false;
......@@ -407,7 +415,7 @@ public class ActionBarMenuItem extends ImageView {
super.onLayout(changed, left, top, right, bottom);
if (popupWindow != null && popupWindow.isShowing()) {
if (showFromBottom) {
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -height + AndroidUtilities.dp(12), -1, -1);
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY(), -1, -1);
} else {
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
}
......
......@@ -320,7 +320,7 @@ public class DrawerLayoutContainer extends FrameLayout {
}
}
}
if (startedTracking) {
if (startedTracking || drawerPosition != 0 && drawerPosition != drawerLayout.getMeasuredWidth()) {
float velX = velocityTracker.getXVelocity();
float velY = velocityTracker.getYVelocity();
boolean backAnimation = drawerPosition < drawerLayout.getMeasuredWidth() / 2.0f && (velX < 1500 || Math.abs(velX) < Math.abs(velY)) || velX < 0 && Math.abs(velX) >= 1500;
......@@ -458,10 +458,12 @@ public class DrawerLayoutContainer extends FrameLayout {
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.0f));
if (alpha != 0) {
shadowLeft.setBounds(drawerPosition, child.getTop(), drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom());
shadowLeft.setAlpha((int) (0xff * alpha));
shadowLeft.draw(canvas);
}
}
return result;
}
}
......@@ -247,6 +247,7 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
((UserCell) view).setChecked(checkedMap.containsKey(user.id));
}
} else {
((ProfileSearchCell) view).setData(user, null, null, name, username);
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
if (ignoreUsers != null) {
if (ignoreUsers.containsKey(user.id)) {
......
......@@ -18,12 +18,33 @@ import org.telegram.ui.Animation.AnimatorListenerAdapter10;
import org.telegram.ui.Animation.AnimatorSet10;
import org.telegram.ui.Animation.View10;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
public class AnimatorSetProxy {
private Object animatorSet;
public static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
return copyOfRange(original, 0, newLength, newType);
}
@SuppressWarnings("unchecked")
public static <T, U> T[] copyOfRange(U[] original, int start, int end, Class<? extends T[]> newType) {
if (start > end) {
throw new IllegalArgumentException();
}
int originalLength = original.length;
if (start < 0 || start > originalLength) {
throw new ArrayIndexOutOfBoundsException();
}
int resultLength = end - start;
int copyLength = Math.min(resultLength, originalLength - start);
T[] result = (T[]) Array.newInstance(newType.getComponentType(), resultLength);
System.arraycopy(original, start, result, 0, copyLength);
return result;
}
public AnimatorSetProxy() {
if (View10.NEED_PROXY) {
animatorSet = new AnimatorSet10();
......@@ -32,12 +53,13 @@ public class AnimatorSetProxy {
}
}
@SuppressWarnings("unchecked")
public void playTogether(Object... items) {
if (View10.NEED_PROXY) {
Animator10[] animators = Arrays.copyOf(items, items.length, Animator10[].class);
Animator10[] animators = copyOf(items, items.length, Animator10[].class);
((AnimatorSet10) animatorSet).playTogether(animators);
} else {
Animator[] animators = Arrays.copyOf(items, items.length, Animator[].class);
Animator[] animators = copyOf(items, items.length, Animator[].class);
((AnimatorSet) animatorSet).playTogether(animators);
}
}
......@@ -98,4 +120,9 @@ public class AnimatorSetProxy {
((AnimatorSet) animatorSet).setInterpolator(interpolator);
}
}
@Override
public boolean equals(Object o) {
return animatorSet == o;
}
}
......@@ -8,9 +8,11 @@
package org.telegram.ui.AnimationCompat;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.view.animation.Interpolator;
import org.telegram.ui.Animation.AnimatorListenerAdapter10;
import org.telegram.ui.Animation.ObjectAnimator10;
import org.telegram.ui.Animation.View10;
......@@ -110,4 +112,13 @@ public class ObjectAnimatorProxy {
((ObjectAnimator) objectAnimator).cancel();
}
}
public ObjectAnimatorProxy addListener(AnimatorListenerAdapterProxy listener) {
if (View10.NEED_PROXY) {
((ObjectAnimator10) objectAnimator).addListener((AnimatorListenerAdapter10) listener.animatorListenerAdapter);
} else {
((ObjectAnimator) objectAnimator).addListener((AnimatorListenerAdapter) listener.animatorListenerAdapter);
}
return this;
}
}
......@@ -38,6 +38,7 @@ import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
private ListView listView;
private ListAdapter listViewAdapter;
private FrameLayout progressView;
......@@ -93,7 +94,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
......
......@@ -74,6 +74,7 @@ public class ChatActionCell extends BaseCell {
textPaint.linkColor = 0xffffffff;
}
imageReceiver = new ImageReceiver(this);
imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable = new AvatarDrawable();
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
}
......
......@@ -65,6 +65,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
TAG = MediaController.getInstance().generateObserverTag();
avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(25));
seekBar = new SeekBar(context);
seekBar.delegate = this;
progressView = new ProgressView();
......
......@@ -156,6 +156,7 @@ public class ChatBaseCell extends BaseCell {
forwardNamePaint.setTextSize(AndroidUtilities.dp(14));
}
avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
avatarDrawable = new AvatarDrawable();
}
......
......@@ -66,12 +66,13 @@ public class ChatContactCell extends ChatBaseCell {
phonePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
phonePaint.setTextSize(AndroidUtilities.dp(15));
phonePaint.setColor(0xff000000);
phonePaint.setColor(0xff212121);
addContactDrawableIn = getResources().getDrawable(R.drawable.addcontact_blue);
addContactDrawableOut = getResources().getDrawable(R.drawable.addcontact_green);
}
avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
avatarDrawable = new AvatarDrawable();
}
......
......@@ -133,7 +133,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
infoPaint.setTextSize(AndroidUtilities.dp(12));
namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
namePaint.setColor(0xff000000);
namePaint.setColor(0xff212121);
namePaint.setTextSize(AndroidUtilities.dp(16));
docBackPaint = new Paint();
......@@ -827,7 +827,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
menuDrawable = docMenuInDrawable;
}
setDrawableBounds(menuDrawable, photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(50), AndroidUtilities.dp(10));
setDrawableBounds(menuDrawable, photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(44), AndroidUtilities.dp(10));
menuDrawable.draw(canvas);
if (!imageDrawn) {
......
......@@ -566,29 +566,35 @@ public class DialogCell extends BaseCell {
continueUpdate = true;
}
}
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
if (chat == null) {
continueUpdate = true;
}
}
if ((mask & MessagesController.UPDATE_MASK_NAME) != 0) {
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
if (chat == null) {
continueUpdate = true;
}
}
if ((mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
if (user == null) {
continueUpdate = true;
}
}
if ((mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
if (user == null) {
continueUpdate = true;
}
}
if ((mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
if (message != null && lastUnreadState != message.isUnread()) {
continueUpdate = true;
} else if (allowPrintStrings) {
TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(currentDialogId);
if (dialog != null && unreadCount != dialog.unread_count) {
unreadCount = dialog.unread_count;
continueUpdate = true;
}
}
}
......
/*
* 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 ShadowBottomSectionCell extends View {
private void init() {
setBackgroundResource(R.drawable.greydivider_bottom);
}
public ShadowBottomSectionCell(Context context) {
super(context);
init();
}
public ShadowBottomSectionCell(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ShadowBottomSectionCell(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public ShadowBottomSectionCell(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(6), MeasureSpec.EXACTLY));
}
}
......@@ -31,7 +31,7 @@ public class TextCell extends FrameLayout {
super(context);
textView = new TextView(context);
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
......
......@@ -18,9 +18,10 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Views.Switch;
public class TextCheckCell extends FrameLayout {
public class TextCheckCell extends FrameLayoutFixed {
private TextView textView;
private Switch checkBox;
......@@ -37,7 +38,7 @@ public class TextCheckCell extends FrameLayout {
}
textView = new TextView(context);
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
......
......@@ -40,7 +40,7 @@ public class TextColorCell extends FrameLayout {
}
textView = new TextView(context);
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
......
......@@ -29,7 +29,7 @@ public class TextDetailCell extends FrameLayout {
super(context);
textView = new TextView(context);
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
......
/*
* 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.Typeface;
import android.text.TextUtils;
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.BackupImageView;
public class TextDetailDocumentsCell extends FrameLayout {
private TextView textView;
private TextView valueTextView;
private TextView typeTextView;
private BackupImageView imageView;
public TextDetailDocumentsCell(Context context) {
super(context);
textView = new TextView(context);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
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(LocaleController.isRTL ? 16 : 71);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16);
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.RIGHT : Gravity.LEFT);
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(LocaleController.isRTL ? 16 : 71);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16);
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
valueTextView.setLayoutParams(layoutParams);
typeTextView = new TextView(context);
typeTextView.setBackgroundColor(0xff757575);
typeTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
typeTextView.setGravity(Gravity.CENTER);
typeTextView.setSingleLine(true);
typeTextView.setTextColor(0xffd1d1d1);
typeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
typeTextView.setTypeface(Typeface.DEFAULT_BOLD);
addView(typeTextView);
layoutParams = (LayoutParams) typeTextView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(40);
layoutParams.height = AndroidUtilities.dp(40);
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
typeTextView.setLayoutParams(layoutParams);
imageView = new BackupImageView(context);
addView(imageView);
layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(40);
layoutParams.height = AndroidUtilities.dp(40);
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
imageView.setLayoutParams(layoutParams);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY));
}
public void setTextAndValueAndTypeAndThumb(String text, String value, String type, String thumb, int resId) {
textView.setText(text);
valueTextView.setText(value);
if (type != null) {
typeTextView.setVisibility(VISIBLE);
typeTextView.setText(type);
} else {
typeTextView.setVisibility(GONE);
}
if (thumb != null || resId != 0) {
if (thumb != null) {
imageView.setImage(thumb, "40_40", null);
} else {
imageView.setImageResource(resId);
}
imageView.setVisibility(VISIBLE);
} else {
imageView.setVisibility(GONE);
}
}
}
......@@ -13,13 +13,13 @@ 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.FrameLayoutFixed;
public class TextDetailSettingsCell extends FrameLayout {
public class TextDetailSettingsCell extends FrameLayoutFixed {
private TextView textView;
private TextView valueTextView;
......@@ -37,7 +37,7 @@ public class TextDetailSettingsCell extends FrameLayout {
}
textView = new TextView(context);
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
......
......@@ -6,77 +6,42 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Views;
package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.FrameLayout;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
public class SettingsSectionLayout extends LinearLayout {
public class TextInfoPrivacyCell extends FrameLayout {
private TextView textView;
private void init() {
setOrientation(LinearLayout.VERTICAL);
public TextInfoPrivacyCell(Context context) {
super(context);
textView = new TextView(getContext());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
textView.setTextColor(0xff3b84c0);
textView = new TextView(context);
textView.setTextColor(0xffa3a3a3);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
textView.setPadding(0, AndroidUtilities.dp(6), 0, AndroidUtilities.dp(16));
addView(textView);
LayoutParams layoutParams = (LayoutParams)textView.getLayoutParams();
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(8);
layoutParams.rightMargin = AndroidUtilities.dp(8);
layoutParams.topMargin = AndroidUtilities.dp(6);
layoutParams.bottomMargin = AndroidUtilities.dp(4);
if (LocaleController.isRTL) {
textView.setGravity(Gravity.RIGHT);
layoutParams.gravity = Gravity.RIGHT;
}
layoutParams.leftMargin = AndroidUtilities.dp(17);
layoutParams.rightMargin = AndroidUtilities.dp(17);
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
textView.setLayoutParams(layoutParams);
View view = new View(getContext());
view.setBackgroundColor(0xff6caae4);
addView(view);
layoutParams = (LayoutParams)view.getLayoutParams();
layoutParams.weight = LayoutParams.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(1);
view.setLayoutParams(layoutParams);
}
public SettingsSectionLayout(Context context) {
super(context);
init();
}
public SettingsSectionLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public SettingsSectionLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public SettingsSectionLayout(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(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.UNSPECIFIED));
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
public void setText(String text) {
......
......@@ -15,6 +15,7 @@ import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
......@@ -24,6 +25,7 @@ public class TextSettingsCell extends FrameLayout {
private TextView textView;
private TextView valueTextView;
private ImageView valueImageView;
private static Paint paint;
private boolean needDivider;
......@@ -37,7 +39,7 @@ public class TextSettingsCell extends FrameLayout {
}
textView = new TextView(context);
textView.setTextColor(0xff000000);
textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
......@@ -69,6 +71,18 @@ public class TextSettingsCell extends FrameLayout {
layoutParams.rightMargin = AndroidUtilities.dp(17);
layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT;
valueTextView.setLayoutParams(layoutParams);
valueImageView = new ImageView(context);
valueImageView.setScaleType(ImageView.ScaleType.CENTER);
valueImageView.setVisibility(GONE);
addView(valueImageView);
layoutParams = (LayoutParams) valueImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 17 : 0);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 17);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL;
valueImageView.setLayoutParams(layoutParams);
}
@Override
......@@ -77,6 +91,9 @@ public class TextSettingsCell extends FrameLayout {
int availableWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - AndroidUtilities.dp(34);
int width = availableWidth / 2;
if (valueImageView.getVisibility() == VISIBLE) {
valueImageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
}
if (valueTextView.getVisibility() == VISIBLE) {
valueTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
width = availableWidth - valueTextView.getMeasuredWidth() - AndroidUtilities.dp(8);
......@@ -99,8 +116,26 @@ public class TextSettingsCell extends FrameLayout {
public void setTextAndValue(String text, String value, boolean divider) {
textView.setText(text);
valueImageView.setVisibility(GONE);
if (value != null) {
valueTextView.setText(value);
valueTextView.setVisibility(VISIBLE);
} else {
valueTextView.setVisibility(GONE);
}
needDivider = divider;
setWillNotDraw(!divider);
}
public void setTextAndIcon(String text, int resId, boolean divider) {
textView.setText(text);
valueTextView.setVisibility(GONE);
if (resId != 0) {
valueImageView.setVisibility(VISIBLE);
valueImageView.setImageResource(resId);
} else {
valueImageView.setVisibility(GONE);
}
needDivider = divider;
setWillNotDraw(!divider);
}
......
......@@ -16,6 +16,7 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
......@@ -74,25 +75,31 @@ public class ChangeChatNameActivity extends BaseFragment {
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
fragmentView = new LinearLayout(inflater.getContext());
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fragmentView.setPadding(0, AndroidUtilities.dp(8), 0, 0);
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
firstNameField = new EditText(inflater.getContext());
firstNameField.setText(currentChat.title);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
firstNameField.setHintTextColor(0xffa3a3a3);
firstNameField.setTextColor(0xff000000);
firstNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121);
firstNameField.setMaxLines(3);
firstNameField.setPadding(0, 0, 0, 0);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
AndroidUtilities.clearCursorDrawable(firstNameField);
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
......@@ -104,17 +111,14 @@ public class ChangeChatNameActivity extends BaseFragment {
return false;
}
});
if (LocaleController.isRTL) {
firstNameField.setGravity(Gravity.RIGHT);
}
((LinearLayout) fragmentView).addView(firstNameField);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(15);
layoutParams.leftMargin = AndroidUtilities.dp(16);
layoutParams.rightMargin = AndroidUtilities.dp(16);
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
firstNameField.setLayoutParams(layoutParams);
if (chat_id > 0) {
......
......@@ -15,6 +15,7 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
......@@ -35,7 +36,6 @@ import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Views.SettingsSectionLayout;
public class ChangeNameActivity extends BaseFragment {
......@@ -67,9 +67,7 @@ public class ChangeNameActivity extends BaseFragment {
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
if (user == null) {
......@@ -78,25 +76,34 @@ public class ChangeNameActivity extends BaseFragment {
fragmentView = new LinearLayout(inflater.getContext());
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fragmentView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), 0);
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
SettingsSectionLayout settingsSectionLayout = new SettingsSectionLayout(inflater.getContext());
((LinearLayout) fragmentView).addView(settingsSectionLayout);
settingsSectionLayout.setText(LocaleController.getString("YourFirstNameAndLastName", R.string.YourFirstNameAndLastName).toUpperCase());
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
firstNameField = new EditText(inflater.getContext());
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
firstNameField.setHintTextColor(0xffa3a3a3);
firstNameField.setTextColor(0xff000000);
firstNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121);
firstNameField.setMaxLines(1);
firstNameField.setLines(1);
firstNameField.setSingleLine(true);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
AndroidUtilities.clearCursorDrawable(firstNameField);
((LinearLayout) fragmentView).addView(firstNameField);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
firstNameField.setLayoutParams(layoutParams);
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
......@@ -108,26 +115,27 @@ public class ChangeNameActivity extends BaseFragment {
return false;
}
});
AndroidUtilities.clearCursorDrawable(firstNameField);
((LinearLayout) fragmentView).addView(firstNameField);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(15);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
firstNameField.setLayoutParams(layoutParams);
lastNameField = new EditText(inflater.getContext());
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
lastNameField.setHintTextColor(0xffa3a3a3);
lastNameField.setTextColor(0xff000000);
lastNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
lastNameField.setHintTextColor(0xff979797);
lastNameField.setTextColor(0xff212121);
lastNameField.setMaxLines(1);
lastNameField.setLines(1);
lastNameField.setSingleLine(true);
lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
AndroidUtilities.clearCursorDrawable(lastNameField);
((LinearLayout) fragmentView).addView(lastNameField);
layoutParams = (LinearLayout.LayoutParams)lastNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(16);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
lastNameField.setLayoutParams(layoutParams);
lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
......@@ -138,13 +146,6 @@ public class ChangeNameActivity extends BaseFragment {
return false;
}
});
AndroidUtilities.clearCursorDrawable(lastNameField);
((LinearLayout) fragmentView).addView(lastNameField);
layoutParams = (LinearLayout.LayoutParams)lastNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(10);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
lastNameField.setLayoutParams(layoutParams);
if (user != null) {
firstNameField.setText(user.first_name);
......@@ -190,6 +191,7 @@ public class ChangeNameActivity extends BaseFragment {
user.last_name = req.last_name;
}
UserConfig.saveConfig(true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
......
......@@ -21,6 +21,7 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
......@@ -43,7 +44,6 @@ import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Views.SettingsSectionLayout;
import java.util.ArrayList;
......@@ -77,7 +77,7 @@ public class ChangeUsernameActivity extends BaseFragment {
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
if (user == null) {
......@@ -86,20 +86,21 @@ public class ChangeUsernameActivity extends BaseFragment {
fragmentView = new LinearLayout(inflater.getContext());
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fragmentView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), 0);
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
SettingsSectionLayout settingsSectionLayout = new SettingsSectionLayout(inflater.getContext());
((LinearLayout) fragmentView).addView(settingsSectionLayout);
settingsSectionLayout.setText(LocaleController.getString("Username", R.string.Username).toUpperCase());
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
firstNameField = new EditText(inflater.getContext());
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
firstNameField.setHintTextColor(0xffa3a3a3);
firstNameField.setTextColor(0xff000000);
firstNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121);
firstNameField.setMaxLines(1);
firstNameField.setLines(1);
firstNameField.setPadding(0, 0, 0, 0);
firstNameField.setSingleLine(true);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
......@@ -119,9 +120,11 @@ public class ChangeUsernameActivity extends BaseFragment {
((LinearLayout) fragmentView).addView(firstNameField);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(15);
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
firstNameField.setLayoutParams(layoutParams);
if (user != null && user.username != null && user.username.length() > 0) {
......@@ -131,7 +134,6 @@ public class ChangeUsernameActivity extends BaseFragment {
checkTextView = new TextView(inflater.getContext());
checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
checkTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0);
checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
((LinearLayout) fragmentView).addView(checkTextView);
layoutParams = (LinearLayout.LayoutParams)checkTextView.getLayoutParams();
......@@ -139,12 +141,13 @@ public class ChangeUsernameActivity extends BaseFragment {
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
checkTextView.setLayoutParams(layoutParams);
TextView helpTextView = new TextView(inflater.getContext());
helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
helpTextView.setTextColor(0xff6d6d72);
helpTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0);
helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
helpTextView.setText(Html.fromHtml(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
((LinearLayout) fragmentView).addView(helpTextView);
......@@ -153,6 +156,8 @@ public class ChangeUsernameActivity extends BaseFragment {
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
helpTextView.setLayoutParams(layoutParams);
firstNameField.addTextChangedListener(new TextWatcher() {
......
......@@ -8,9 +8,6 @@
package org.telegram.ui;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
......@@ -41,7 +38,6 @@ import android.webkit.MimeTypeMap;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
......@@ -65,6 +61,10 @@ import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.Cells.ChatActionCell;
import org.telegram.ui.Cells.ChatAudioCell;
import org.telegram.ui.Cells.ChatBaseCell;
......@@ -79,9 +79,10 @@ import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Views.ChatActivityEnterView;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Views.LayoutListView;
import org.telegram.ui.Views.SizeNotifierRelativeLayout;
import org.telegram.ui.Views.TimerButton;
import org.telegram.ui.Views.TimerDrawable;
import org.telegram.ui.Views.TypingDotsDrawable;
import java.io.File;
......@@ -98,13 +99,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TLRPC.EncryptedChat currentEncryptedChat;
private boolean userBlocked = false;
private View topPanel;
private View progressView;
private View bottomOverlay;
private ChatAdapter chatAdapter;
private ChatActivityEnterView chatActivityEnterView;
private View timeItem;
private View menuItem;
private ActionBarMenuItem timeItem;
private TimerDrawable timerDrawable;
private ActionBarMenuItem menuItem;
private TextView addContactItem;
private LayoutListView chatListView;
private BackupImageView avatarImageView;
private TextView bottomOverlayChatText;
......@@ -116,12 +118,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TextView onlineTextView;
private FrameLayout avatarContainer;
private TextView bottomOverlayText;
private TextView secretViewStatusTextView;
private TextView selectedMessagesCountTextView;
private MessageObject selectedObject;
private MessageObject forwaringMessage;
private TextView secretViewStatusTextView;
private TimerButton timerButton;
private TextView selectedMessagesCountTextView;
private boolean paused = true;
private boolean readWhenResume = false;
......@@ -130,9 +131,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean scrollToTopOnResume = false;
private boolean scrollToTopUnReadOnResume = false;
private boolean isCustomTheme = false;
private ImageView topPlaneClose;
private View pagedownButton;
private TextView topPanelText;
private long dialog_id;
private boolean isBroadcast = false;
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>();
......@@ -188,6 +187,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private final static int attach_video = 8;
private final static int attach_document = 9;
private final static int attach_location = 10;
private final static int clear_history = 11;
private final static int delete_chat = 12;
private final static int share_contact = 13;
AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() {
@Override
......@@ -438,18 +440,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat != null) {
MediaController.getInstance().stopMediaObserver();
}
if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
AndroidUtilities.unlockOrientation(getParentActivity());
MediaController.getInstance().stopAudio();
}
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
lastPrintString = null;
lastStatus = null;
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) {
public void onItemClick(final int id) {
if (id == -1) {
finishFragment();
} else if (id == -2) {
......@@ -606,17 +613,79 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MessagesActivity fragment = new MessagesActivity(args);
fragment.setDelegate(ChatActivity.this);
presentFragment(fragment);
} else if (id == chat_enc_timer) {
if (getParentActivity() == null) {
return;
}
showAlertDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat));
} else if (id == clear_history || id == delete_chat) {
final boolean isChat = (int)dialog_id < 0 && (int)(dialog_id >> 32) != 1;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
if (id == clear_history) {
builder.setMessage(LocaleController.getString("AreYouSureClearHistory", R.string.AreYouSureClearHistory));
} else {
if (isChat) {
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
} else {
builder.setMessage(LocaleController.getString("AreYouSureDeleteThisChat", R.string.AreYouSureDeleteThisChat));
}
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MessagesController.getInstance().deleteDialog(dialog_id, 0, id == clear_history);
if (id != clear_history) {
if (isChat) {
MessagesController.getInstance().deleteUserFromChat((int) -dialog_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
}
finishFragment();
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (id == share_contact) {
if (currentUser == null || getParentActivity() == null) {
return;
}
if (currentUser.phone != null && currentUser.phone.length() != 0) {
Bundle args = new Bundle();
args.putInt("user_id", currentUser.id);
args.putBoolean("addContact", true);
presentFragment(new ContactAddActivity(args));
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo));
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) {
SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id);
chatListView.post(new Runnable() {
@Override
public void run() {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
}
}
}
});
avatarContainer = new FrameLayout(getParentActivity());
avatarContainer = new FrameLayoutFixed(getParentActivity());
avatarContainer.setBackgroundResource(R.drawable.bar_selector);
avatarContainer.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0);
actionBar.addView(avatarContainer);
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
layoutParams2.height = AndroidUtilities.dp(48);
layoutParams2.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.rightMargin = AndroidUtilities.dp(48 + (currentEncryptedChat != null ? 48 : 0));
layoutParams2.leftMargin = AndroidUtilities.dp(64);
layoutParams2.rightMargin = AndroidUtilities.dp(40);
layoutParams2.leftMargin = AndroidUtilities.dp(56);
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
avatarContainer.setLayoutParams(layoutParams2);
avatarContainer.setOnClickListener(new View.OnClickListener() {
......@@ -657,6 +726,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.width = AndroidUtilities.dp(42);
layoutParams2.height = AndroidUtilities.dp(42);
layoutParams2.topMargin = AndroidUtilities.dp(3);
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
avatarImageView.setLayoutParams(layoutParams2);
nameTextView = new TextView(getParentActivity());
......@@ -708,43 +778,42 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ActionBarMenu menu = actionBar.createMenu();
if (currentEncryptedChat != null) {
timeItem = menu.addItemResource(chat_enc_timer, R.layout.chat_header_enc_layout);
timeItem = menu.addItem(chat_enc_timer, timerDrawable = new TimerDrawable(getParentActivity()));
} else {
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
if (currentUser != null) {
addContactItem = item.addSubItem(share_contact, "", 0);
}
item.addSubItem(clear_history, LocaleController.getString("ClearHistory", R.string.ClearHistory), 0);
if (currentChat != null && !isBroadcast) {
item.addSubItem(delete_chat, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit), 0);
} else {
item.addSubItem(delete_chat, LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser), 0);
}
}
ActionBarMenuItem item = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach);
item.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo);
item.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery);
item.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video);
item.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc);
item.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location);
menuItem = item;
item.setShowFromBottom(true);
item.setBackground(null);
menuItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach);
menuItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo);
menuItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery);
menuItem.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video);
menuItem.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc);
menuItem.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location);
menuItem.setShowFromBottom(true);
menuItem.setBackgroundDrawable(null);
actionModeViews.clear();
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());
layout.setBackgroundColor(0xffe5e5e5);
actionMode.addView(layout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)layout.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(1);
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.topMargin = AndroidUtilities.dp(12);
layoutParams.bottomMargin = AndroidUtilities.dp(12);
layoutParams.gravity = Gravity.CENTER_VERTICAL;
layout.setLayoutParams(layoutParams);
actionModeViews.add(layout);
actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
selectedMessagesCountTextView = new TextView(actionMode.getContext());
selectedMessagesCountTextView.setTextSize(18);
selectedMessagesCountTextView.setTextColor(0xff000000);
selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
selectedMessagesCountTextView.setTextColor(0xff737373);
selectedMessagesCountTextView.setSingleLine(true);
selectedMessagesCountTextView.setLines(1);
selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, 0);
selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2));
selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
......@@ -753,7 +822,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
actionMode.addView(selectedMessagesCountTextView);
layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
layoutParams.weight = 1;
layoutParams.width = 0;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
......@@ -785,9 +854,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
emptyView.setText(LocaleController.getString("NoMessages", R.string.NoMessages));
chatListView = (LayoutListView)fragmentView.findViewById(R.id.chat_list_view);
chatListView.setAdapter(chatAdapter = new ChatAdapter(getParentActivity()));
topPanel = fragmentView.findViewById(R.id.top_panel);
topPlaneClose = (ImageView)fragmentView.findViewById(R.id.top_plane_close);
topPanelText = (TextView)fragmentView.findViewById(R.id.top_panel_text);
bottomOverlay = fragmentView.findViewById(R.id.bottom_overlay);
bottomOverlayText = (TextView)fragmentView.findViewById(R.id.bottom_overlay_text);
bottomOverlayChat = fragmentView.findViewById(R.id.bottom_overlay_chat);
......@@ -1148,37 +1214,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (show) {
if (pagedownButton.getVisibility() == View.GONE) {
if (Build.VERSION.SDK_INT > 13 && animated) {
if (animated) {
pagedownButton.setVisibility(View.VISIBLE);
pagedownButton.setAlpha(0);
pagedownButton.animate().alpha(1).setDuration(200).setListener(null).start();
ViewProxy.setAlpha(pagedownButton, 0);
ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "alpha", 1.0f).setDuration(200).start();
} else {
pagedownButton.setVisibility(View.VISIBLE);
}
}
} else {
if (pagedownButton.getVisibility() == View.VISIBLE) {
if (Build.VERSION.SDK_INT > 13 && animated) {
pagedownButton.animate().alpha(0).setDuration(200).setListener(new Animator.AnimatorListener() {
if (animated) {
ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "alpha", 0.0f).setDuration(200).addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
public void onAnimationEnd(Object animation) {
pagedownButton.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}).start();
} else {
pagedownButton.setVisibility(View.GONE);
......@@ -1241,17 +1292,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (timeItem != null) {
timerButton = (TimerButton)timeItem.findViewById(R.id.chat_timer);
timerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
showAlertDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat));
}
});
timerButton.setTime(currentEncryptedChat.ttl);
timerDrawable.setTime(currentEncryptedChat.ttl);
}
checkAndUpdateAvatar();
......@@ -1426,11 +1467,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
if (!selectedMessagesIds.isEmpty()) {
selectedMessagesCountTextView.setText(LocaleController.formatString("Selected", R.string.Selected, selectedMessagesIds.size()));
selectedMessagesCountTextView.setText(String.format("%d", selectedMessagesIds.size()));
}
}
private void updateTitle() {
if (nameTextView == null) {
return;
}
if (currentChat != null) {
nameTextView.setText(currentChat.title);
} else if (currentUser != null) {
......@@ -1447,6 +1491,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updateSubtitle() {
if (onlineTextView == null) {
return;
}
CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id);
if (printString != null) {
printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""});
......@@ -1493,15 +1540,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (start) {
try {
if (onlineTextView != null) {
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null);
onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
}
if (typingDotsDrawable != null) {
typingDotsDrawable.start();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
if (onlineTextView != null) {
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
onlineTextView.setCompoundDrawablePadding(0);
}
if (typingDotsDrawable != null) {
typingDotsDrawable.stop();
}
......@@ -1989,9 +2042,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction &&
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerButton != null) {
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerDrawable != null) {
TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL)obj.messageOwner.action.encryptedAction;
timerButton.setTime(action.ttl_seconds);
timerDrawable.setTime(action.ttl_seconds);
}
if (obj.isOut() && obj.isSending()) {
scrollToLastMessage();
......@@ -2035,9 +2088,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int oldCount = messages.size();
for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction &&
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerButton != null) {
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerDrawable != null) {
TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL)obj.messageOwner.action.encryptedAction;
timerButton.setTime(action.ttl_seconds);
timerDrawable.setTime(action.ttl_seconds);
}
if (messagesDict.containsKey(obj.messageOwner.id)) {
continue;
......@@ -2383,11 +2436,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updateContactStatus() {
if (topPanel == null) {
if (addContactItem == null) {
return;
}
if (currentUser == null) {
topPanel.setVisibility(View.GONE);
addContactItem.setVisibility(View.GONE);
} else {
TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id);
if (user != null) {
......@@ -2398,74 +2451,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|| currentUser instanceof TLRPC.TL_userEmpty || currentUser instanceof TLRPC.TL_userDeleted
|| ContactsController.getInstance().isLoadingContacts()
|| (currentUser.phone != null && currentUser.phone.length() != 0 && ContactsController.getInstance().contactsDict.get(currentUser.id) != null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts()))) {
topPanel.setVisibility(View.GONE);
addContactItem.setVisibility(View.GONE);
} else {
topPanel.setVisibility(View.VISIBLE);
topPanelText.setShadowLayer(1, 0, AndroidUtilities.dp(1), 0xff8797a3);
if (isCustomTheme) {
topPlaneClose.setImageResource(R.drawable.ic_msg_btn_cross_custom);
topPanel.setBackgroundResource(R.drawable.top_pane_custom);
} else {
topPlaneClose.setImageResource(R.drawable.ic_msg_btn_cross_custom);
topPanel.setBackgroundResource(R.drawable.top_pane);
}
addContactItem.setVisibility(View.VISIBLE);
if (currentUser.phone != null && currentUser.phone.length() != 0) {
if (MessagesController.getInstance().hidenAddToContacts.get(currentUser.id) != null) {
topPanel.setVisibility(View.INVISIBLE);
} else {
topPanelText.setText(LocaleController.getString("AddToContacts", R.string.AddToContacts));
topPlaneClose.setVisibility(View.VISIBLE);
topPlaneClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MessagesController.getInstance().hidenAddToContacts.put(currentUser.id, currentUser);
topPanel.setVisibility(View.GONE);
}
});
topPanel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("user_id", currentUser.id);
args.putBoolean("addContact", true);
presentFragment(new ContactAddActivity(args));
}
});
}
} else {
if (MessagesController.getInstance().hidenAddToContacts.get(currentUser.id) != null) {
topPanel.setVisibility(View.INVISIBLE);
addContactItem.setText(LocaleController.getString("AddToContacts", R.string.AddToContacts));
} else {
topPanelText.setText(LocaleController.getString("ShareMyContactInfo", R.string.ShareMyContactInfo));
topPlaneClose.setVisibility(View.GONE);
topPanel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo));
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) {
MessagesController.getInstance().hidenAddToContacts.put(currentUser.id, currentUser);
topPanel.setVisibility(View.GONE);
SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id);
chatListView.post(new Runnable() {
@Override
public void run() {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
}
});
}
addContactItem.setText(LocaleController.getString("ShareMyContactInfo", R.string.ShareMyContactInfo));
}
}
}
......@@ -2475,7 +2467,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onResume() {
super.onResume();
if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
checkActionBarMenu();
......@@ -2605,12 +2599,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return false;
}
if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
selectedMessagesCountTextView.setTextSize(16);
} else {
selectedMessagesCountTextView.setTextSize(18);
} else {
selectedMessagesCountTextView.setTextSize(20);
}
int padding = (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)avatarContainer.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
avatarContainer.setLayoutParams(layoutParams);
return false;
}
......@@ -2799,21 +2795,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
actionBar.showActionMode();
if (Build.VERSION.SDK_INT >= 11) {
AnimatorSet animatorSet = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<Animator>();
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
ArrayList<Object> animators = new ArrayList<Object>();
for (int a = 0; a < actionModeViews.size(); a++) {
View view = actionModeViews.get(a);
if (a < 2) {
animators.add(ObjectAnimator.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0));
AndroidUtilities.clearDrawableAnimation(view);
if (a < 1) {
animators.add(ObjectAnimatorProxy.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0));
} else {
animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f));
animators.add(ObjectAnimatorProxy.ofFloat(view, "scaleY", 0.1f, 1.0f));
}
}
animatorSet.playTogether(animators);
animatorSet.setDuration(250);
animatorSet.start();
}
addToSelectedMessages(message);
updateActionModeTitle();
updateVisibleRows();
......@@ -2951,9 +2948,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putInt("chat_id", -lower_part);
}
forwardSelectedMessages(did, param);
presentFragment(new ChatActivity(args), true);
ChatActivity chatActivity = new ChatActivity(args);
presentFragment(chatActivity, true);
if (!AndroidUtilities.isTablet()) {
removeSelfFromStack();
chatActivity.getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
} else {
activity.finishFragment();
......@@ -3095,7 +3094,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = chatListView;
object.imageReceiver = imageReceiver;
object.thumb = object.imageReceiver.getBitmap();
object.thumb = imageReceiver.getBitmap();
object.radius = imageReceiver.getRoundRadius();
return object;
}
}
......
......@@ -10,14 +10,21 @@ package org.telegram.ui;
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.InputType;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
......@@ -40,8 +47,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
private EditText firstNameField;
private EditText lastNameField;
private BackupImageView avatarImage;
private TextView onlineText;
private TextView phoneText;
private TextView nameTextView;
private TextView onlineTextView;
private int user_id;
private boolean addContact;
......@@ -98,27 +105,148 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
/*
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user.phone == null) {
if (phone != null) {
user.phone = PhoneFormat.stripExceptNumbers(phone);
}
<LinearLayout
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/settings_avatar_image"
android:layout_width="64dp"
android:layout_height="64dp"/>
<LinearLayout
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_marginBottom="1dp">
<TextView
android:textSize="21dp"
android:textColor="#333333"
android:ellipsize="end"
android:id="@+id/settings_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"/>
<TextView
android:textSize="14dp"
android:textColor="#999999"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:id="@+id/settings_online"/>
</LinearLayout>
</LinearLayout>
*/
fragmentView = new ScrollView(getParentActivity());
LinearLayout linearLayout = new LinearLayout(getParentActivity());
linearLayout.setOrientation(LinearLayout.VERTICAL);
((ScrollView) fragmentView).addView(linearLayout);
ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT;
layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT;
linearLayout.setLayoutParams(layoutParams2);
linearLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
FrameLayout frameLayout = new FrameLayout(getParentActivity());
linearLayout.addView(frameLayout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
frameLayout.setLayoutParams(layoutParams);
onlineText = (TextView)fragmentView.findViewById(R.id.settings_online);
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
avatarImage = new BackupImageView(getParentActivity());
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
avatarImage.processDetach = false;
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
phoneText = (TextView)fragmentView.findViewById(R.id.settings_name);
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
phoneText.setTypeface(typeface);
frameLayout.addView(avatarImage);
FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
layoutParams3.width = AndroidUtilities.dp(60);
layoutParams3.height = AndroidUtilities.dp(60);
avatarImage.setLayoutParams(layoutParams3);
firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field);
nameTextView = new TextView(getParentActivity());
nameTextView.setTextColor(0xff212121);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
nameTextView.setLines(1);
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
frameLayout.addView(nameTextView);
layoutParams3 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
layoutParams3.topMargin = AndroidUtilities.dp(3);
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
nameTextView.setLayoutParams(layoutParams3);
onlineTextView = new TextView(getParentActivity());
onlineTextView.setTextColor(0xff999999);
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setLines(1);
onlineTextView.setMaxLines(1);
onlineTextView.setSingleLine(true);
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
frameLayout.addView(onlineTextView);
layoutParams3 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
layoutParams3.topMargin = AndroidUtilities.dp(32);
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
onlineTextView.setLayoutParams(layoutParams3);
firstNameField = new EditText(inflater.getContext());
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121);
firstNameField.setMaxLines(1);
firstNameField.setLines(1);
firstNameField.setSingleLine(true);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
AndroidUtilities.clearCursorDrawable(firstNameField);
linearLayout.addView(firstNameField);
layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
firstNameField.setLayoutParams(layoutParams);
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
......@@ -130,8 +258,27 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
return false;
}
});
lastNameField = (EditText)fragmentView.findViewById(R.id.last_name_field);
lastNameField = new EditText(inflater.getContext());
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
lastNameField.setHintTextColor(0xff979797);
lastNameField.setTextColor(0xff212121);
lastNameField.setMaxLines(1);
lastNameField.setLines(1);
lastNameField.setSingleLine(true);
lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
AndroidUtilities.clearCursorDrawable(lastNameField);
linearLayout.addView(lastNameField);
layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(16);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
lastNameField.setLayoutParams(layoutParams);
lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
......@@ -143,7 +290,13 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
}
});
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user != null) {
if (user.phone == null) {
if (phone != null) {
user.phone = PhoneFormat.stripExceptNumbers(phone);
}
}
firstNameField.setText(user.first_name);
firstNameField.setSelection(firstNameField.length());
lastNameField.setText(user.last_name);
......@@ -151,7 +304,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
updateAvatarLayout();
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
......@@ -160,15 +313,15 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
}
private void updateAvatarLayout() {
if (phoneText == null) {
if (nameTextView == null) {
return;
}
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null) {
return;
}
phoneText.setText(PhoneFormat.getInstance().format("+" + user.phone));
onlineText.setText(LocaleController.formatUserStatus(user));
nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
onlineTextView.setText(LocaleController.formatUserStatus(user));
TLRPC.FileLocation photo = null;
if (user.photo != null) {
......@@ -179,7 +332,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
int mask = (Integer) args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateAvatarLayout();
}
......
......@@ -25,6 +25,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
......@@ -183,27 +184,44 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
fragmentView = new FrameLayout(getParentActivity());
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
((FrameLayout) fragmentView).addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
emptyTextLayout.setLayoutParams(layoutParams);
emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
emptyTextLayout.addView(emptyTextView);
LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1);
FrameLayout frameLayout = new FrameLayout(getParentActivity());
emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1);
listView = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
......@@ -348,6 +366,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (absListView.isFastScrollEnabled()) {
AndroidUtilities.clearDrawableAnimation(absListView);
}
}
});
} else {
......
......@@ -18,6 +18,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
......@@ -127,27 +128,44 @@ public class CountrySelectActivity extends BaseFragment {
fragmentView = new FrameLayout(getParentActivity());
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
((FrameLayout) fragmentView).addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
emptyTextLayout.setLayoutParams(layoutParams);
emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyTextLayout.addView(emptyTextView);
LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1);
FrameLayout frameLayout = new FrameLayout(getParentActivity());
emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1);
listView = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
......@@ -198,6 +216,9 @@ public class CountrySelectActivity extends BaseFragment {
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (absListView.isFastScrollEnabled()) {
AndroidUtilities.clearDrawableAnimation(absListView);
}
}
});
} else {
......
......@@ -24,6 +24,7 @@ import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
import org.telegram.messenger.R;
......@@ -32,7 +33,7 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Cells.TextDetailDocumentsCell;
import org.telegram.ui.ActionBar.BaseFragment;
import java.io.BufferedReader;
......@@ -261,6 +262,7 @@ public class DocumentSelectActivity extends BaseFragment {
} else {
emptyView.setText(LocaleController.getString("NotMounted", R.string.NotMounted));
}
AndroidUtilities.clearDrawableAnimation(listView);
listAdapter.notifyDataSetChanged();
return true;
}
......@@ -309,6 +311,7 @@ public class DocumentSelectActivity extends BaseFragment {
item.file = file;
if (file.isDirectory()) {
item.icon = R.drawable.ic_directory;
item.subtitle = LocaleController.getString("Folder", R.string.Folder);
} else {
String fname = file.getName();
String[] sp = fname.split("\\.");
......@@ -323,10 +326,11 @@ public class DocumentSelectActivity extends BaseFragment {
}
ListItem item = new ListItem();
item.title = "..";
item.subtitle = "";
item.subtitle = LocaleController.getString("Folder", R.string.Folder);
item.icon = R.drawable.ic_directory;
item.file = null;
items.add(0, item);
AndroidUtilities.clearDrawableAnimation(listView);
listAdapter.notifyDataSetChanged();
return true;
}
......@@ -335,11 +339,7 @@ public class DocumentSelectActivity extends BaseFragment {
if (getParentActivity() == null) {
return;
}
new AlertDialog.Builder(getParentActivity())
.setTitle(LocaleController.getString("AppName", R.string.AppName))
.setMessage(error)
.setPositiveButton(R.string.OK, null)
.show();
new AlertDialog.Builder(getParentActivity()).setTitle(LocaleController.getString("AppName", R.string.AppName)).setMessage(error).setPositiveButton(R.string.OK, null).show();
}
private void listRoots() {
......@@ -420,6 +420,7 @@ public class DocumentSelectActivity extends BaseFragment {
FileLog.e("tmessages", e);
}
AndroidUtilities.clearDrawableAnimation(listView);
listAdapter.notifyDataSetChanged();
}
......@@ -465,35 +466,18 @@ public class DocumentSelectActivity extends BaseFragment {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (convertView == null) {
convertView = new TextDetailDocumentsCell(mContext);
}
TextDetailDocumentsCell textDetailCell = (TextDetailDocumentsCell) convertView;
ListItem item = items.get(position);
if (v == null) {
v = View.inflate(mContext, R.layout.document_item, null);
if (item.subtitle.length() == 0) {
v.findViewById(R.id.docs_item_info).setVisibility(View.GONE);
}
}
TextView typeTextView = (TextView)v.findViewById(R.id.docs_item_type);
((TextView)v.findViewById(R.id.docs_item_title)).setText(item.title);
((TextView)v.findViewById(R.id.docs_item_info)).setText(item.subtitle);
BackupImageView imageView = (BackupImageView)v.findViewById(R.id.docs_item_thumb);
if (item.thumb != null) {
imageView.setImageBitmap(null);
typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4)));
imageView.setImage(item.thumb, "55_42", null);
imageView.setVisibility(View.VISIBLE);
typeTextView.setVisibility(View.VISIBLE);
} else if (item.icon != 0) {
imageView.setImageResource(item.icon);
imageView.setVisibility(View.VISIBLE);
typeTextView.setVisibility(View.GONE);
if (item.icon != 0) {
((TextDetailDocumentsCell) convertView).setTextAndValueAndTypeAndThumb(item.title, item.subtitle, null, null, item.icon);
} else {
typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4)));
imageView.setVisibility(View.GONE);
typeTextView.setVisibility(View.VISIBLE);
String type = item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4));
((TextDetailDocumentsCell) convertView).setTextAndValueAndTypeAndThumb(item.title, item.subtitle, type, item.thumb, 0);
}
return v;
return convertView;
}
}
}
......@@ -59,7 +59,11 @@ import java.util.HashMap;
public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
public class XImageSpan extends ImageSpan {
public static interface GroupCreateActivityDelegate {
public abstract void didSelectUsers(ArrayList<Integer> ids);
}
private class XImageSpan extends ImageSpan {
public int uid;
public XImageSpan(Drawable d, int verticalAlignment) {
......@@ -90,10 +94,14 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
private SectionsListView listView;
private ContactsSearchAdapter searchListViewAdapter;
private GroupCreateActivityDelegate delegate;
private int beforeChangeIndex;
private int maxCount = 200;
private boolean ignoreChange = false;
private boolean isBroadcast = false;
private boolean isAlwaysShare = false;
private boolean isNeverShare = false;
private boolean searchWas;
private boolean searching;
private CharSequence changeString;
......@@ -109,6 +117,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
public GroupCreateActivity(Bundle args) {
super(args);
isBroadcast = args.getBoolean("broadcast", false);
isAlwaysShare = args.getBoolean("isAlwaysShare", false);
isNeverShare = args.getBoolean("isNeverShare", false);
maxCount = !isBroadcast ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount;
}
......@@ -136,8 +146,14 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
if (isAlwaysShare) {
actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
} else if (isNeverShare) {
actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
} else {
actionBar.setTitle(isBroadcast ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList) : LocaleController.getString("NewGroup", R.string.NewGroup));
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
......@@ -145,9 +161,17 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (id == -1) {
finishFragment();
} else if (id == done_button) {
if (!selectedContacts.isEmpty()) {
if (selectedContacts.isEmpty()) {
return;
}
ArrayList<Integer> result = new ArrayList<Integer>();
result.addAll(selectedContacts.keySet());
if (isAlwaysShare || isNeverShare) {
if (delegate != null) {
delegate.didSelectUsers(result);
}
finishFragment();
} else {
Bundle args = new Bundle();
args.putIntegerArrayList("result", result);
args.putBoolean("broadcast", isBroadcast);
......@@ -157,7 +181,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
});
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
searchListViewAdapter.setCheckedMap(selectedContacts);
......@@ -179,8 +203,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
userSelectEditText = new EditText(getParentActivity());
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
userSelectEditText.setHintTextColor(0xffa6a6a6);
userSelectEditText.setTextColor(0xff000000);
userSelectEditText.setHintTextColor(0xff979797);
userSelectEditText.setTextColor(0xff212121);
userSelectEditText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
userSelectEditText.setMinimumHeight(AndroidUtilities.dp(54));
userSelectEditText.setSingleLine(false);
......@@ -201,7 +225,13 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams1.gravity = Gravity.TOP;
userSelectEditText.setLayoutParams(layoutParams1);
if (isAlwaysShare) {
userSelectEditText.setHint(LocaleController.getString("AlwaysShareWithPlaceholder", R.string.AlwaysShareWithPlaceholder));
} else if (isNeverShare) {
userSelectEditText.setHint(LocaleController.getString("NeverShareWithPlaceholder", R.string.NeverShareWithPlaceholder));
} else {
userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
}
if (Build.VERSION.SDK_INT >= 11) {
userSelectEditText.setTextIsSelectable(false);
}
......@@ -243,7 +273,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
selectedContacts.remove(sp.uid);
}
}
if (!isAlwaysShare && !isNeverShare) {
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
}
listView.invalidateViews();
} else {
search = true;
......@@ -288,27 +320,43 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
});
LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(emptyTextLayout);
layoutParams = (LinearLayout.LayoutParams) emptyTextLayout.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
emptyTextLayout.setLayoutParams(layoutParams);
emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
linearLayout.addView(emptyTextView);
emptyTextLayout.addView(emptyTextView);
layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
layoutParams.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
emptyTextLayout.addView(frameLayout2);
layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.weight = 0.5f;
frameLayout2.setLayoutParams(layoutParams);
listView = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
......@@ -361,7 +409,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
span.uid = user.id;
ignoreChange = false;
}
if (!isAlwaysShare && !isNeverShare) {
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
}
if (searching || searchWas) {
ignoreChange = true;
SpannableStringBuilder ssb = new SpannableStringBuilder("");
......@@ -400,6 +450,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (absListView.isFastScrollEnabled()) {
AndroidUtilities.clearDrawableAnimation(absListView);
}
}
});
} else {
......@@ -434,7 +487,11 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
}
public XImageSpan createAndPutChipForUser(TLRPC.User user) {
public void setDelegate(GroupCreateActivityDelegate delegate) {
this.delegate = delegate;
}
private XImageSpan createAndPutChipForUser(TLRPC.User user) {
LayoutInflater lf = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View textView = lf.inflate(R.layout.group_create_bubble, null);
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
......
......@@ -184,7 +184,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
});
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = new LinearLayout(getParentActivity());
LinearLayout linearLayout = (LinearLayout) fragmentView;
......@@ -198,6 +198,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
frameLayout.setLayoutParams(layoutParams);
avatarImage = new BackupImageView(getParentActivity());
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable.setInfo(5, null, null, isBroadcast);
avatarImage.setImageDrawable(avatarDrawable);
frameLayout.addView(avatarImage);
......@@ -254,12 +255,12 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
nameTextView.setMaxLines(4);
nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
nameTextView.setHintTextColor(0xffa6a6a6);
nameTextView.setHintTextColor(0xff979797);
nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
AndroidUtilities.clearCursorDrawable(nameTextView);
nameTextView.setTextColor(0xff000000);
nameTextView.setTextColor(0xff212121);
frameLayout.addView(nameTextView);
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
......
......@@ -20,6 +20,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
......@@ -94,7 +95,6 @@ public class LanguageSelectActivity extends BaseFragment {
if (text.length() != 0) {
searchWas = true;
if (listView != null) {
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
listView.setAdapter(searchListViewAdapter);
}
}
......@@ -106,27 +106,44 @@ public class LanguageSelectActivity extends BaseFragment {
fragmentView = new FrameLayout(getParentActivity());
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
((FrameLayout) fragmentView).addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
emptyTextLayout.setLayoutParams(layoutParams);
emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyTextLayout.addView(emptyTextView);
LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1);
FrameLayout frameLayout = new FrameLayout(getParentActivity());
emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1);
listView = new ListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
......
/*
* 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;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
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.ContactsController;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
import java.util.ArrayList;
public class LastSeenActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private ListAdapter listAdapter;
private View doneButton;
private int currentType = 0;
private ArrayList<Integer> currentPlus;
private ArrayList<Integer> currentMinus;
private int lastSeenSectionRow;
private int everybodyRow;
private int myContactsRow;
private int nobodyRow;
private int lastSeenDetailRow;
private int shareSectionRow;
private int alwaysShareRow;
private int neverShareRow;
private int shareDetailRow;
private int rowCount;
private final static int done_button = 1;
private static class LinkMovementMethodMy extends LinkMovementMethod {
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
try {
return super.onTouchEvent(widget, buffer, event);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return false;
}
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
checkPrivacy();
updateRows();
NotificationCenter.getInstance().addObserver(this, NotificationCenter.privacyRulesUpdated);
return true;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.privacyRulesUpdated);
}
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == done_button) {
TLRPC.TL_account_setPrivacy req = new TLRPC.TL_account_setPrivacy();
req.key = new TLRPC.TL_inputPrivacyKeyStatusTimestamp();
if (currentType != 0 && currentPlus.size() > 0) {
TLRPC.TL_inputPrivacyValueAllowUsers rule = new TLRPC.TL_inputPrivacyValueAllowUsers();
for (Integer uid : currentPlus) {
TLRPC.User user = MessagesController.getInstance().getUser(uid);
if (user != null) {
TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
if (inputUser != null) {
rule.users.add(inputUser);
}
}
}
req.rules.add(rule);
}
if (currentType != 1 && currentMinus.size() > 0) {
TLRPC.TL_inputPrivacyValueDisallowUsers rule = new TLRPC.TL_inputPrivacyValueDisallowUsers();
for (Integer uid : currentMinus) {
TLRPC.User user = MessagesController.getInstance().getUser(uid);
if (user != null) {
TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
if (inputUser != null) {
rule.users.add(inputUser);
}
}
}
req.rules.add(rule);
}
if (currentType == 0) {
req.rules.add(new TLRPC.TL_inputPrivacyValueAllowAll());
} else if (currentType == 1) {
req.rules.add(new TLRPC.TL_inputPrivacyValueDisallowAll());
} else if (currentType == 2) {
req.rules.add(new TLRPC.TL_inputPrivacyValueAllowContacts());
}
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (error == null) {
finishFragment();
TLRPC.TL_account_privacyRules rules = (TLRPC.TL_account_privacyRules) response;
MessagesController.getInstance().putUsers(rules.users, false);
ContactsController.getInstance().setPrivacyRules(rules.rules);
} else {
showErrorAlert();
}
}
});
}
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
doneButton.setVisibility(View.GONE);
listAdapter = new ListAdapter(getParentActivity());
fragmentView = new FrameLayout(getParentActivity());
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(0xfff0f0f0);
ListView listView = new ListView(getParentActivity());
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
listView.setDrawSelectorOnTop(true);
frameLayout.addView(listView);
FrameLayout.LayoutParams 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
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
if (i == nobodyRow || i == everybodyRow || i == myContactsRow) {
int newType = currentType;
if (i == nobodyRow) {
newType = 1;
} else if (i == everybodyRow) {
newType = 0;
} else if (i == myContactsRow) {
newType = 2;
}
if (newType == currentType) {
return;
}
doneButton.setVisibility(View.VISIBLE);
currentType = newType;
updateRows();
} else if (i == neverShareRow || i == alwaysShareRow) {
ArrayList<Integer> createFromArray = null;
if (i == neverShareRow) {
createFromArray = currentMinus;
} else {
createFromArray = currentPlus;
}
if (createFromArray.isEmpty()) {
Bundle args = new Bundle();
args.putBoolean(i == neverShareRow ? "isNeverShare" : "isAlwaysShare", true);
GroupCreateActivity fragment = new GroupCreateActivity(args);
fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
@Override
public void didSelectUsers(ArrayList<Integer> ids) {
if (i == neverShareRow) {
currentMinus = ids;
} else {
currentPlus = ids;
}
doneButton.setVisibility(View.VISIBLE);
listAdapter.notifyDataSetChanged();
}
});
presentFragment(fragment);
} else {
LastSeenUsersActivity fragment = new LastSeenUsersActivity(createFromArray, i == alwaysShareRow);
fragment.setDelegate(new LastSeenUsersActivity.LastSeenUsersActivityDelegate() {
@Override
public void didUpdatedUserList(ArrayList<Integer> ids, boolean added) {
if (i == neverShareRow) {
currentMinus = ids;
if (added) {
for (Integer id : currentMinus) {
currentPlus.remove(id);
}
}
} else {
currentPlus = ids;
if (added) {
for (Integer id : currentPlus) {
currentMinus.remove(id);
}
}
}
doneButton.setVisibility(View.VISIBLE);
listAdapter.notifyDataSetChanged();
}
});
presentFragment(fragment);
}
}
}
});
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView;
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.privacyRulesUpdated) {
checkPrivacy();
}
}
private void showErrorAlert() {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("PrivacyFloodControlError", R.string.PrivacyFloodControlError));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showAlertDialog(builder);
}
private void checkPrivacy() {
currentPlus = new ArrayList<Integer>();
currentMinus = new ArrayList<Integer>();
ArrayList<TLRPC.PrivacyRule> privacyRules = ContactsController.getInstance().getPrivacyRules();
if (privacyRules.size() == 0) {
currentType = 1;
return;
}
int type = -1;
for (TLRPC.PrivacyRule rule : privacyRules) {
if (rule instanceof TLRPC.TL_privacyValueAllowUsers) {
currentPlus.addAll(rule.users);
} else if (rule instanceof TLRPC.TL_privacyValueDisallowUsers) {
currentMinus.addAll(rule.users);
} else if (rule instanceof TLRPC.TL_privacyValueAllowAll) {
type = 0;
} else if (rule instanceof TLRPC.TL_privacyValueDisallowAll) {
type = 1;
} else {
type = 2;
}
}
if (type == 0 || type == -1 && currentMinus.size() > 0) {
currentType = 0;
} else if (type == 2 || type == -1 && currentMinus.size() > 0 && currentPlus.size() > 0) {
currentType = 2;
} else if (type == 1 || type == -1 && currentPlus.size() > 0) {
currentType = 1;
}
if (doneButton != null) {
doneButton.setVisibility(View.GONE);
}
updateRows();
}
private void updateRows() {
rowCount = 0;
lastSeenSectionRow = rowCount++;
everybodyRow = rowCount++;
myContactsRow = rowCount++;
nobodyRow = rowCount++;
lastSeenDetailRow = rowCount++;
shareSectionRow = rowCount++;
if (currentType == 1 || currentType == 2) {
alwaysShareRow = rowCount++;
} else {
alwaysShareRow = -1;
}
if (currentType == 0 || currentType == 2) {
neverShareRow = rowCount++;
} else {
neverShareRow = -1;
}
shareDetailRow = rowCount++;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
private class ListAdapter extends BaseFragmentAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public boolean isEnabled(int i) {
return i == nobodyRow || i == everybodyRow || i == myContactsRow || i == neverShareRow || i == alwaysShareRow;
}
@Override
public int getCount() {
return rowCount;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new TextSettingsCell(mContext);
view.setBackgroundColor(0xffffffff);
}
TextSettingsCell textCell = (TextSettingsCell) view;
if (i == everybodyRow) {
textCell.setTextAndIcon(LocaleController.getString("LastSeenEverybody", R.string.LastSeenEverybody), currentType == 0 ? R.drawable.check_blue : 0, true);
} else if (i == myContactsRow) {
textCell.setTextAndIcon(LocaleController.getString("LastSeenContacts", R.string.LastSeenContacts), currentType == 2 ? R.drawable.check_blue : 0, true);
} else if (i == nobodyRow) {
textCell.setTextAndIcon(LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody), currentType == 1 ? R.drawable.check_blue : 0, false);
} else if (i == alwaysShareRow) {
String value;
if (currentPlus.size() != 0) {
value = LocaleController.formatPluralString("Users", currentPlus.size());
} else {
value = LocaleController.getString("EmpryUsersPlaceholder", R.string.EmpryUsersPlaceholder);
}
textCell.setTextAndValue(LocaleController.getString("AlwaysShareWith", R.string.AlwaysShareWith), value, neverShareRow != -1);
} else if (i == neverShareRow) {
String value;
if (currentMinus.size() != 0) {
value = LocaleController.formatPluralString("Users", currentMinus.size());
} else {
value = LocaleController.getString("EmpryUsersPlaceholder", R.string.EmpryUsersPlaceholder);
}
textCell.setTextAndValue(LocaleController.getString("NeverShareWith", R.string.NeverShareWith), value, false);
}
} else if (type == 1) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view.setBackgroundColor(0xffffffff);
}
if (i == lastSeenDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("CustomHelp", R.string.CustomHelp));
view.setBackgroundResource(R.drawable.greydivider);
} else if (i == shareDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("CustomShareSettingsHelp", R.string.CustomShareSettingsHelp));
view.setBackgroundResource(R.drawable.greydivider_bottom);
}
} else if (type == 2) {
if (view == null) {
view = new HeaderCell(mContext);
view.setBackgroundColor(0xffffffff);
}
if (i == lastSeenSectionRow) {
((HeaderCell) view).setText(LocaleController.getString("LastSeenTitle", R.string.LastSeenTitle));
} else if (i == shareSectionRow) {
((HeaderCell) view).setText(LocaleController.getString("AddExceptions", R.string.AddExceptions));
}
}
return view;
}
@Override
public int getItemViewType(int i) {
if (i == alwaysShareRow || i == neverShareRow || i == everybodyRow || i == myContactsRow || i == nobodyRow) {
return 0;
} else if (i == shareDetailRow || i == lastSeenDetailRow) {
return 1;
} else if (i == lastSeenSectionRow || i == shareSectionRow) {
return 2;
}
return 0;
}
@Override
public int getViewTypeCount() {
return 3;
}
@Override
public boolean isEmpty() {
return false;
}
}
}
/*
* This is the source code of Telegram for Android v. 2.0.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;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
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.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.TextInfoCell;
import org.telegram.ui.Cells.UserCell;
import java.util.ArrayList;
public class LastSeenUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
public static interface LastSeenUsersActivityDelegate {
public abstract void didUpdatedUserList(ArrayList<Integer> ids, boolean added);
}
private ListView listView;
private ListAdapter listViewAdapter;
private int selectedUserId;
private ArrayList<Integer> uidArray;
private boolean isAlwaysShare;
private LastSeenUsersActivityDelegate delegate;
private final static int block_user = 1;
public LastSeenUsersActivity(ArrayList<Integer> users, boolean always) {
super();
uidArray = users;
isAlwaysShare = always;
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
return true;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
}
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
if (isAlwaysShare) {
actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
} else {
actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == block_user) {
Bundle args = new Bundle();
args.putBoolean(isAlwaysShare ? "isAlwaysShare" : "isNeverShare", true);
GroupCreateActivity fragment = new GroupCreateActivity(args);
fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
@Override
public void didSelectUsers(ArrayList<Integer> ids) {
for (Integer id : ids) {
if (uidArray.contains(id)) {
continue;
}
uidArray.add(id);
}
listViewAdapter.notifyDataSetChanged();
if (delegate != null) {
delegate.didUpdatedUserList(uidArray, true);
}
}
});
presentFragment(fragment);
}
}
});
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(block_user, R.drawable.plus);
fragmentView = new FrameLayout(getParentActivity());
FrameLayout frameLayout = (FrameLayout) fragmentView;
TextView emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
frameLayout.addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
listView = new ListView(getParentActivity());
listView.setEmptyView(emptyTextView);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
if (Build.VERSION.SDK_INT >= 11) {
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
}
frameLayout.addView(listView);
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
listView.setLayoutParams(layoutParams);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i < uidArray.size()) {
Bundle args = new Bundle();
args.putInt("user_id", uidArray.get(i));
presentFragment(new ProfileActivity(args));
}
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i < 0 || i >= uidArray.size() || getParentActivity() == null) {
return true;
}
selectedUserId = uidArray.get(i);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] {LocaleController.getString("Delete", R.string.Delete)};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
uidArray.remove((Integer)selectedUserId);
listViewAdapter.notifyDataSetChanged();
if (delegate != null) {
delegate.didUpdatedUserList(uidArray, false);
}
}
}
});
showAlertDialog(builder);
return true;
}
});
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView;
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer)args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateVisibleRows(mask);
}
}
}
private void updateVisibleRows(int mask) {
if (listView == null) {
return;
}
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
}
}
}
public void setDelegate(LastSeenUsersActivityDelegate delegate) {
this.delegate = delegate;
}
@Override
public void onResume() {
super.onResume();
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
}
private class ListAdapter extends BaseFragmentAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public boolean isEnabled(int i) {
return i != uidArray.size();
}
@Override
public int getCount() {
if (uidArray.isEmpty()) {
return 0;
}
return uidArray.size() + 1;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new UserCell(mContext, 1);
}
TLRPC.User user = MessagesController.getInstance().getUser(uidArray.get(i));
((UserCell)view).setData(user, null, user.phone != null && user.phone.length() != 0 ? PhoneFormat.getInstance().format("+" + user.phone) : LocaleController.getString("NumberUnknown", R.string.NumberUnknown), 0);
} else if (type == 1) {
if (view == null) {
view = new TextInfoCell(mContext);
((TextInfoCell) view).setText(LocaleController.getString("RemoveFromListText", R.string.RemoveFromListText));
}
}
return view;
}
@Override
public int getItemViewType(int i) {
if(i == uidArray.size()) {
return 1;
}
return 0;
}
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public boolean isEmpty() {
return uidArray.isEmpty();
}
}
}
......@@ -27,11 +27,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
......@@ -61,28 +61,28 @@ import java.util.ArrayList;
import java.util.Map;
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate {
private boolean finished = false;
private String videoPath = null;
private String sendingText = null;
private ArrayList<Uri> photoPathsArray = null;
private ArrayList<String> documentsPathsArray = null;
private ArrayList<String> documentsOriginalPathsArray = null;
private ArrayList<TLRPC.User> contactsToSend = null;
private boolean finished;
private String videoPath;
private String sendingText;
private ArrayList<Uri> photoPathsArray;
private ArrayList<String> documentsPathsArray;
private ArrayList<String> documentsOriginalPathsArray;
private ArrayList<TLRPC.User> contactsToSend;
private int currentConnectionState;
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<BaseFragment>();
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<BaseFragment>();
private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<BaseFragment>();
private ActionBarLayout actionBarLayout = null;
private ActionBarLayout layersActionBarLayout = null;
private ActionBarLayout rightActionBarLayout = null;
private FrameLayout shadowTablet = null;
private LinearLayout buttonLayoutTablet = null;
private FrameLayout shadowTabletSide = null;
private ImageView backgroundTablet = null;
private DrawerLayoutContainer drawerLayoutContainer = null;
private ActionBarLayout actionBarLayout;
private ActionBarLayout layersActionBarLayout;
private ActionBarLayout rightActionBarLayout;
private FrameLayout shadowTablet;
private FrameLayout shadowTabletSide;
private ImageView backgroundTablet;
private DrawerLayoutContainer drawerLayoutContainer;
private DrawerLayoutAdapter drawerLayoutAdapter;
private boolean tabletFullSize = false;
private boolean tabletFullSize;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -114,14 +114,66 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
super.onCreate(savedInstanceState);
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
actionBarLayout = new ActionBarLayout(this);
drawerLayoutContainer = new DrawerLayoutContainer(this);
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (AndroidUtilities.isTablet()) {
setContentView(R.layout.launch_layout_tablet);
shadowTablet = (FrameLayout)findViewById(R.id.shadow_tablet);
buttonLayoutTablet = (LinearLayout)findViewById(R.id.launch_button_layout);
shadowTabletSide = (FrameLayout)findViewById(R.id.shadow_tablet_side);
backgroundTablet = (ImageView)findViewById(R.id.launch_background);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
RelativeLayout launchLayout = new RelativeLayout(this);
drawerLayoutContainer.addView(launchLayout);
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams();
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT;
launchLayout.setLayoutParams(layoutParams1);
backgroundTablet = new ImageView(this);
backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP);
backgroundTablet.setImageResource(R.drawable.cats);
launchLayout.addView(backgroundTablet);
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet.getLayoutParams();
relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
backgroundTablet.setLayoutParams(relativeLayoutParams);
launchLayout.addView(actionBarLayout);
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(relativeLayoutParams);
rightActionBarLayout = new ActionBarLayout(this);
launchLayout.addView(rightActionBarLayout);
relativeLayoutParams = (RelativeLayout.LayoutParams)rightActionBarLayout.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.dp(320);
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
rightActionBarLayout.setLayoutParams(relativeLayoutParams);
rightActionBarLayout.init(rightFragmentsStack);
rightActionBarLayout.setDelegate(this);
shadowTabletSide = new FrameLayout(this);
shadowTabletSide.setBackgroundColor(0x40295274);
launchLayout.addView(shadowTabletSide);
relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.dp(1);
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
shadowTabletSide.setLayoutParams(relativeLayoutParams);
shadowTablet = new FrameLayout(this);
shadowTablet.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x7F000000);
launchLayout.addView(shadowTablet);
relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams();
relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
shadowTablet.setLayoutParams(relativeLayoutParams);
shadowTablet.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
......@@ -157,98 +209,31 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
});
RelativeLayout launchLayout = (RelativeLayout)findViewById(R.id.launch_layout);
layersActionBarLayout = new ActionBarLayout(this);
layersActionBarLayout.setRemoveActionBarExtraHeight(true);
layersActionBarLayout.setBackgroundView(shadowTablet);
layersActionBarLayout.setUseAlphaAnimations(true);
layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
launchLayout.addView(layersActionBarLayout);
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.dp(498);
relativeLayoutParams.height = AndroidUtilities.dp(528);
relativeLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
layersActionBarLayout.setLayoutParams(relativeLayoutParams);
layersActionBarLayout.init(layerFragmentsStack);
layersActionBarLayout.setDelegate(this);
layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
layersActionBarLayout.setVisibility(View.GONE);
launchLayout.addView(actionBarLayout, 2);
relativeLayoutParams = (RelativeLayout.LayoutParams)actionBarLayout.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.dp(320);
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(relativeLayoutParams);
rightActionBarLayout = new ActionBarLayout(this);
launchLayout.addView(rightActionBarLayout, 3);
relativeLayoutParams = (RelativeLayout.LayoutParams)rightActionBarLayout.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.dp(320);
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
rightActionBarLayout.setLayoutParams(relativeLayoutParams);
rightActionBarLayout.init(rightFragmentsStack);
rightActionBarLayout.setDelegate(this);
TextView button = (TextView)findViewById(R.id.new_group_button);
button.setText(LocaleController.getString("NewGroup", R.string.NewGroup));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presentFragment(new GroupCreateActivity());
}
});
button = (TextView)findViewById(R.id.new_secret_button);
button.setText(LocaleController.getString("NewSecretChat", R.string.NewSecretChat));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true);
args.putBoolean("createSecretChat", true);
presentFragment(new ContactsActivity(args));
}
});
button = (TextView)findViewById(R.id.new_broadcast_button);
button.setText(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args));
}
});
button = (TextView)findViewById(R.id.contacts_button);
button.setText(LocaleController.getString("Contacts", R.string.Contacts));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presentFragment(new ContactsActivity(null));
}
});
button = (TextView)findViewById(R.id.settings_button);
button.setText(LocaleController.getString("Settings", R.string.Settings));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presentFragment(new SettingsActivity());
}
});
} else {
drawerLayoutContainer = new DrawerLayoutContainer(this);
drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
ListView listView = new ListView(this);
listView.setAdapter(new DrawerLayoutAdapter(this));
listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this));
drawerLayoutContainer.setDrawerLayout(listView);
listView.setBackgroundColor(0xffffffff);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)listView.getLayoutParams();
Point screenSize = AndroidUtilities.getRealScreenSize();
layoutParams.width = Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56);
layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56);
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
listView.setPadding(0, 0, 0, 0);
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
......@@ -303,30 +288,26 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
});
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
}
actionBarLayout.init(mainFragmentsStack);
actionBarLayout.setDelegate(this);
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
if (actionBarLayout.fragmentsStack.isEmpty()) {
if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false);
} else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true);
}
try {
......@@ -672,18 +653,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (UserConfig.isClientActivated()) {
if (actionBarLayout.fragmentsStack.isEmpty()) {
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true);
}
} else {
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
layersActionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false);
}
}
} else {
if (actionBarLayout.fragmentsStack.isEmpty()) {
if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false);
} else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true);
}
}
}
......@@ -781,6 +766,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
finished = true;
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState);
}
......@@ -795,6 +781,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
public void needLayout() {
if (AndroidUtilities.isTablet()) {
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
relativeLayoutParams.leftMargin = (AndroidUtilities.displaySize.x - relativeLayoutParams.width) / 2;
int y = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
relativeLayoutParams.topMargin = y + (AndroidUtilities.displaySize.y - relativeLayoutParams.height - y) / 2;
layersActionBarLayout.setLayoutParams(relativeLayoutParams);
if (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
tabletFullSize = false;
int leftWidth = AndroidUtilities.displaySize.x / 100 * 35;
......@@ -802,7 +795,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
leftWidth = AndroidUtilities.dp(320);
}
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams.width = leftWidth;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(relativeLayoutParams);
......@@ -817,12 +810,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
relativeLayoutParams.leftMargin = leftWidth;
rightActionBarLayout.setLayoutParams(relativeLayoutParams);
relativeLayoutParams = (RelativeLayout.LayoutParams) buttonLayoutTablet.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.displaySize.x - leftWidth;
relativeLayoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
relativeLayoutParams.leftMargin = leftWidth;
buttonLayoutTablet.setLayoutParams(relativeLayoutParams);
if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) {
BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1);
chatFragment.onPause();
......@@ -833,13 +820,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
rightActionBarLayout.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
buttonLayoutTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() && rightActionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
backgroundTablet.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
shadowTabletSide.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
} else {
tabletFullSize = true;
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(relativeLayoutParams);
......@@ -847,7 +833,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
shadowTabletSide.setVisibility(View.GONE);
rightActionBarLayout.setVisibility(View.GONE);
backgroundTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
buttonLayoutTablet.setVisibility(View.GONE);
if (rightActionBarLayout.fragmentsStack.size() == 1) {
BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0);
......@@ -974,6 +959,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
currentConnectionState = state;
//actionBarLayout.getActionBar().setBackOverlayVisible(currentConnectionState != 0);
}
} else if (id == NotificationCenter.mainUserInfoChanged) {
drawerLayoutAdapter.notifyDataSetChanged();
}
}
......@@ -1118,8 +1105,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
if (AndroidUtilities.isTablet()) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE);
if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.getDelegate() == null && layout != actionBarLayout) {
......@@ -1127,10 +1114,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
layersActionBarLayout.removeAllFragments();
layersActionBarLayout.setVisibility(View.GONE);
drawerLayoutContainer.setAllowOpenDrawer(true);
if (!tabletFullSize) {
shadowTabletSide.setVisibility(View.VISIBLE);
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
buttonLayoutTablet.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.VISIBLE);
}
}
......@@ -1140,7 +1127,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (fragment instanceof ChatActivity) {
if (!tabletFullSize && layout != rightActionBarLayout) {
rightActionBarLayout.setVisibility(View.VISIBLE);
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.GONE);
rightActionBarLayout.removeAllFragments();
rightActionBarLayout.presentFragment(fragment, removeLast, true, false);
......@@ -1177,8 +1163,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false);
if (fragment instanceof LoginActivity) {
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000);
......@@ -1190,14 +1176,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
return true;
} else {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
return true;
}
}
@Override
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
if (AndroidUtilities.isTablet()) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE);
if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.getDelegate() == null && layout != actionBarLayout) {
......@@ -1205,10 +1192,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.addFragmentToStack(fragment);
layersActionBarLayout.removeAllFragments();
layersActionBarLayout.setVisibility(View.GONE);
drawerLayoutContainer.setAllowOpenDrawer(true);
if (!tabletFullSize) {
shadowTabletSide.setVisibility(View.VISIBLE);
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
buttonLayoutTablet.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.VISIBLE);
}
}
......@@ -1217,7 +1204,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (fragment instanceof ChatActivity) {
if (!tabletFullSize && layout != rightActionBarLayout) {
rightActionBarLayout.setVisibility(View.VISIBLE);
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.GONE);
rightActionBarLayout.removeAllFragments();
rightActionBarLayout.addFragmentToStack(fragment);
......@@ -1242,8 +1228,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false);
if (fragment instanceof LoginActivity) {
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000);
......@@ -1255,6 +1241,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
return true;
} else {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
return true;
}
}
......@@ -1268,7 +1255,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
return false;
} else if (layout == rightActionBarLayout) {
if (!tabletFullSize) {
buttonLayoutTablet.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.VISIBLE);
}
} else if (layout == layersActionBarLayout && actionBarLayout.fragmentsStack.isEmpty() && layersActionBarLayout.fragmentsStack.size() == 1) {
......@@ -1294,17 +1280,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
rightActionBarLayout.showLastFragment();
actionBarLayout.rebuildAllFragmentViews(true);
actionBarLayout.showLastFragment();
TextView button = (TextView)findViewById(R.id.new_group_button);
button.setText(LocaleController.getString("NewGroup", R.string.NewGroup));
button = (TextView)findViewById(R.id.new_secret_button);
button.setText(LocaleController.getString("NewSecretChat", R.string.NewSecretChat));
button = (TextView)findViewById(R.id.new_broadcast_button);
button.setText(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
button = (TextView)findViewById(R.id.contacts_button);
button.setText(LocaleController.getString("Contacts", R.string.Contacts));
button = (TextView)findViewById(R.id.settings_button);
button.setText(LocaleController.getString("Settings", R.string.Settings));
}
}
}
......
......@@ -27,6 +27,7 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
......@@ -145,6 +146,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view);
if (avatarImageView != null) {
avatarImageView.processDetach = false;
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
}
nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label);
distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label);
......
......@@ -117,7 +117,7 @@ public class LoginActivity extends BaseFragment {
});
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = new ScrollView(getParentActivity());
ScrollView scrollView = (ScrollView) fragmentView;
......@@ -207,14 +207,18 @@ public class LoginActivity extends BaseFragment {
@Override
public void onPause() {
super.onPause();
if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
}
@Override
public void onResume() {
super.onResume();
if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
}
private Bundle loadCurrentState() {
try {
......@@ -411,6 +415,7 @@ public class LoginActivity extends BaseFragment {
public void needFinishActivity() {
clearCurrentState();
presentFragment(new MessagesActivity(null), true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
}
public class SlideView extends LinearLayout {
......@@ -989,7 +994,7 @@ public class LoginActivity extends BaseFragment {
codeField.setHintTextColor(0xff979797);
codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
codeField.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
codeField.setInputType(InputType.TYPE_CLASS_NUMBER);
codeField.setMaxLines(1);
codeField.setPadding(0, 0, 0, 0);
addView(codeField);
......
......@@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.HashMap;
public class MediaActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
private GridView listView;
private ListAdapter listAdapter;
private ArrayList<MessageObject> messages = new ArrayList<MessageObject>();
......
......@@ -58,7 +58,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private ListView messagesListView;
private DialogsAdapter dialogsAdapter;
private DialogsSearchAdapter dialogsSearchAdapter;
private TextView searchEmptyView;
private View searchEmptyView;
private View progressView;
private View emptyView;
private ImageView floatingButton;
......@@ -243,14 +243,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
progressView = fragmentView.findViewById(R.id.progressLayout);
dialogsAdapter.notifyDataSetChanged();
searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
searchEmptyView = fragmentView.findViewById(R.id.search_empty_view);
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView = fragmentView.findViewById(R.id.list_empty_view);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
......@@ -258,10 +257,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
return true;
}
});
TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
textView.setText(LocaleController.getString("NoChats", R.string.NoChatsHelp));
textView.setText(LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp));
textView = (TextView)fragmentView.findViewById(R.id.search_empty_text);
textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
floatingButton = (ImageView)fragmentView.findViewById(R.id.floating_button);
floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
......@@ -393,56 +396,40 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
int lower_id = (int)selectedDialog;
int high_id = (int)(selectedDialog >> 32);
if (lower_id < 0 && high_id != 1) {
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory), LocaleController.getString("DeleteChat", R.string.DeleteChat)}, new DialogInterface.OnClickListener() {
final boolean isChat = lower_id < 0 && high_id != 1;
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory),
isChat ? LocaleController.getString("DeleteChat", R.string.DeleteChat) : LocaleController.getString("Delete", R.string.Delete)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, true);
} else if (which == 1) {
public void onClick(DialogInterface dialog, final int which) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
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) {
MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
MessagesController.getInstance().deleteDialog(selectedDialog, 0, false);
if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
}
}
});
} else {
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory), LocaleController.getString("Delete", R.string.Delete)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, true);
builder.setMessage(LocaleController.getString("AreYouSureClearHistory", R.string.AreYouSureClearHistory));
} else {
if (isChat) {
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureDeleteThisChat", R.string.AreYouSureDeleteThisChat));
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) {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, false);
MessagesController.getInstance().deleteDialog(selectedDialog, 0, which == 0);
if (which != 0) {
if (isChat) {
MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
}
if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
}
}
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
return true;
......@@ -545,7 +532,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
emptyView.setVisibility(View.GONE);
messagesListView.setEmptyView(progressView);
} else {
if (messagesListView.getEmptyView() == null) {
if (searching && searchWas) {
messagesListView.setEmptyView(searchEmptyView);
emptyView.setVisibility(View.GONE);
......@@ -553,7 +539,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
messagesListView.setEmptyView(emptyView);
searchEmptyView.setVisibility(View.GONE);
}
}
progressView.setVisibility(View.GONE);
}
}
......
......@@ -353,7 +353,7 @@ public class PhotoCropActivity extends BaseFragment {
});
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = view = new PhotoCropView(getParentActivity());
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
......
......@@ -76,6 +76,7 @@ import java.util.HashMap;
import java.util.Locale;
public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
private int classGuid;
private PhotoViewerProvider placeProvider;
private boolean isVisible;
......@@ -325,6 +326,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
public int user_id;
public int index;
public int size;
public int radius;
}
public static interface PhotoViewerProvider {
......@@ -602,6 +604,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
actionBar = new ActionBar(activity);
actionBar.setBackgroundColor(0x7F000000);
actionBar.setOccupyStatusBar(false);
actionBar.setItemsBackground(R.drawable.bar_selector_white);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
......@@ -1591,6 +1594,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
final Rect drawRegion = object.imageReceiver.getDrawRegion();
animatingImageView.setVisibility(View.VISIBLE);
animatingImageView.setRadius(object.radius);
animatingImageView.setNeedRadius(object.radius != 0);
animatingImageView.setImageBitmap(object.thumb);
ViewProxy.setAlpha(animatingImageView, 1.0f);
......@@ -1643,6 +1648,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal, 0),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop, 0),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom, 0),
ObjectAnimatorProxy.ofInt(animatingImageView, "radius", 0),
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f)
);
......@@ -1731,11 +1737,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
Rect drawRegion = null;
if (object != null) {
animatingImageView.setNeedRadius(object.radius != 0);
drawRegion = object.imageReceiver.getDrawRegion();
layoutParams.width = drawRegion.right - drawRegion.left;
layoutParams.height = drawRegion.bottom - drawRegion.top;
animatingImageView.setImageBitmap(object.thumb);
} else {
animatingImageView.setNeedRadius(false);
layoutParams.width = centerImage.getImageWidth();
layoutParams.height = centerImage.getImageHeight();
animatingImageView.setImageBitmap(centerImage.getBitmap());
......@@ -1782,6 +1790,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom),
ObjectAnimatorProxy.ofInt(animatingImageView, "radius", object.radius),
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f)
);
} else {
......
......@@ -15,6 +15,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.PowerManager;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
......@@ -61,6 +62,9 @@ public class PopupNotificationActivity extends Activity implements NotificationC
private ActionBar actionBar;
private ChatActivityEnterView chatActivityEnterView;
private BackupImageView avatarImageView;
private TextView nameTextView;
private TextView onlineTextView;
private FrameLayout avatarContainer;
private TextView countText;
private ViewGroup messageContainer;
private ViewGroup centerView;
......@@ -182,6 +186,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
popupContainer.addView(messageContainer, 0);
actionBar = new ActionBar(this);
actionBar.setOccupyStatusBar(false);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackgroundResource(R.color.header);
actionBar.setItemsBackground(R.drawable.bar_selector);
......@@ -194,9 +199,62 @@ public class PopupNotificationActivity extends Activity implements NotificationC
View view = menu.addItemResource(2, R.layout.popup_count_layout);
countText = (TextView) view.findViewById(R.id.count_text);
view = menu.addItemResource(1, R.layout.chat_header_layout);
avatarImageView = (BackupImageView)view.findViewById(R.id.chat_avatar_image);
avatarContainer = new FrameLayoutFixed(this);
avatarContainer.setBackgroundResource(R.drawable.bar_selector);
avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
actionBar.addView(avatarContainer);
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
layoutParams2.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.rightMargin = AndroidUtilities.dp(48);
layoutParams2.leftMargin = AndroidUtilities.dp(60);
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
avatarContainer.setLayoutParams(layoutParams2);
avatarImageView = new BackupImageView(this);
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(21));
avatarImageView.processDetach = false;
avatarContainer.addView(avatarImageView);
layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
layoutParams2.width = AndroidUtilities.dp(42);
layoutParams2.height = AndroidUtilities.dp(42);
layoutParams2.topMargin = AndroidUtilities.dp(3);
avatarImageView.setLayoutParams(layoutParams2);
nameTextView = new TextView(this);
nameTextView.setTextColor(0xffffffff);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
nameTextView.setLines(1);
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity(Gravity.LEFT);
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
avatarContainer.addView(nameTextView);
layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.leftMargin = AndroidUtilities.dp(54);
layoutParams2.bottomMargin = AndroidUtilities.dp(22);
layoutParams2.gravity = Gravity.BOTTOM;
nameTextView.setLayoutParams(layoutParams2);
onlineTextView = new TextView(this);
onlineTextView.setTextColor(0xffd7e8f7);
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setLines(1);
onlineTextView.setMaxLines(1);
onlineTextView.setSingleLine(true);
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
onlineTextView.setGravity(Gravity.LEFT);
avatarContainer.addView(onlineTextView);
layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.leftMargin = AndroidUtilities.dp(54);
layoutParams2.bottomMargin = AndroidUtilities.dp(4);
layoutParams2.gravity = Gravity.BOTTOM;
onlineTextView.setLayoutParams(layoutParams2);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
......@@ -616,12 +674,26 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
private void fixLayout() {
if (avatarContainer != null) {
avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
if (avatarContainer != null) {
avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this);
}
int padding = (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
return false;
}
});
}
if (messageContainer != null) {
messageContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
messageContainer.getViewTreeObserver().removeOnPreDrawListener(this);
if (!checkTransitionAnimation() && !startedMoving) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)messageContainer.getLayoutParams();
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) messageContainer.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.getCurrentActionBarHeight();
layoutParams.bottomMargin = AndroidUtilities.dp(48);
layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
......@@ -633,6 +705,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
});
}
}
private void handleIntent(Intent intent) {
KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
......@@ -732,15 +805,18 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
if (currentChat != null && currentUser != null) {
actionBar.setTitle(currentChat.title);
actionBar.setSubtitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
actionBar.setTitleIcon(0, 0);
nameTextView.setText(currentChat.title);
onlineTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
nameTextView.setCompoundDrawablePadding(0);
} else if (currentUser != null) {
actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
if ((int)dialog_id == 0) {
actionBar.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
} else {
actionBar.setTitleIcon(0, 0);
nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
nameTextView.setCompoundDrawablePadding(0);
}
}
......@@ -759,12 +835,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) {
actionBar.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else {
actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
}
} else {
actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
}
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
if (printString == null || printString.length() == 0) {
......@@ -774,10 +850,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (user != null) {
currentUser = user;
}
actionBar.setSubtitle(LocaleController.formatUserStatus(currentUser));
onlineTextView.setText(LocaleController.formatUserStatus(currentUser));
} else {
lastPrintString = printString;
actionBar.setSubtitle(printString);
onlineTextView.setText(printString);
setTypingAnimation(true);
}
}
......@@ -817,13 +893,15 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
if (start) {
try {
actionBar.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4));
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null);
onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
typingDotsDrawable.start();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
actionBar.setSubTitleIcon(0, null, 0);
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
onlineTextView.setCompoundDrawablePadding(0);
typingDotsDrawable.stop();
}
}
......
......@@ -8,7 +8,427 @@
package org.telegram.ui;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
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.Toast;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
import java.util.ArrayList;
public class PrivacySettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private ListAdapter listAdapter;
private int privacySectionRow;
private int blockedRow;
private int lastSeenRow;
private int lastSeenDetailRow;
private int securitySectionRow;
private int terminateSessionsRow;
private int terminateSessionsDetailRow;
private int deleteAccountSectionRow;
private int deleteAccountRow;
private int deleteAccountDetailRow;
private int rowCount;
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
ContactsController.getInstance().loadPrivacySettings();
rowCount = 0;
privacySectionRow = rowCount++;
blockedRow = rowCount++;
lastSeenRow = rowCount++;
lastSeenDetailRow = rowCount++;
securitySectionRow = rowCount++;
terminateSessionsRow = rowCount++;
terminateSessionsDetailRow = rowCount++;
deleteAccountSectionRow = rowCount++;
deleteAccountRow = rowCount++;
deleteAccountDetailRow = rowCount++;
NotificationCenter.getInstance().addObserver(this, NotificationCenter.privacyRulesUpdated);
return true;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.privacyRulesUpdated);
}
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
listAdapter = new ListAdapter(getParentActivity());
fragmentView = new FrameLayout(getParentActivity());
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(0xfff0f0f0);
ListView listView = new ListView(getParentActivity());
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
listView.setDrawSelectorOnTop(true);
frameLayout.addView(listView);
FrameLayout.LayoutParams 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
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
if (i == blockedRow) {
presentFragment(new BlockedUsersActivity());
} else if (i == terminateSessionsRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions));
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) {
TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations();
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (getParentActivity() == null) {
return;
}
if (error == null && response instanceof TLRPC.TL_boolTrue) {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), Toast.LENGTH_SHORT);
toast.show();
} else {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnknownError", R.string.UnknownError), Toast.LENGTH_SHORT);
toast.show();
}
}
});
UserConfig.registeredForPush = false;
UserConfig.registeredForInternalPush = false;
UserConfig.saveConfig(false);
MessagesController.getInstance().registerForPush(UserConfig.pushString);
ConnectionsManager.getInstance().initPushConnection();
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (i == deleteAccountRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle));
builder.setItems(new CharSequence[] {
LocaleController.getString("DeleteAccountNever", R.string.DeleteAccountNever),
LocaleController.formatPluralString("Months", 1),
LocaleController.formatPluralString("Months", 3),
LocaleController.formatPluralString("Months", 6),
LocaleController.formatPluralString("Years", 1)
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int value = 0;
if (which == 1) {
value = 30;
} else if (which == 2) {
value = 60;
} else if (which == 3) {
value = 182;
} else if (which == 4) {
value = 365;
}
final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
final TLRPC.TL_account_setAccountTTL req = new TLRPC.TL_account_setAccountTTL();
req.ttl = new TLRPC.TL_accountDaysTTL();
req.ttl.days = value;
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (response instanceof TLRPC.TL_boolTrue) {
ContactsController.getInstance().setDeleteAccountTTL(req.ttl.days);
listAdapter.notifyDataSetChanged();
}
}
});
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (i == lastSeenRow) {
presentFragment(new LastSeenActivity());
}
}
});
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView;
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.privacyRulesUpdated) {
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
}
private String formatRulesString() {
ArrayList<TLRPC.PrivacyRule> privacyRules = ContactsController.getInstance().getPrivacyRules();
if (privacyRules.size() == 0) {
return LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody);
}
int type = -1;
int plus = 0;
int minus = 0;
for (TLRPC.PrivacyRule rule : privacyRules) {
if (rule instanceof TLRPC.TL_privacyValueAllowUsers) {
plus += rule.users.size();
} else if (rule instanceof TLRPC.TL_privacyValueDisallowUsers) {
minus += rule.users.size();
} else if (rule instanceof TLRPC.TL_privacyValueAllowAll) {
type = 0;
} else if (rule instanceof TLRPC.TL_privacyValueDisallowAll) {
type = 1;
} else {
type = 2;
}
}
if (type == 0 || type == -1 && minus > 0) {
if (minus == 0) {
return LocaleController.getString("LastSeenEverybody", R.string.LastSeenEverybody);
} else {
return LocaleController.formatString("LastSeenEverybodyMinus", R.string.LastSeenEverybodyMinus, minus);
}
} else if (type == 2 || type == -1 && minus > 0 && plus > 0) {
if (plus == 0 && minus == 0) {
return LocaleController.getString("LastSeenContacts", R.string.LastSeenContacts);
} else {
if (plus != 0 && minus != 0) {
return LocaleController.formatString("LastSeenContactsMinusPlus", R.string.LastSeenContactsMinusPlus, minus, plus);
} else if (minus != 0) {
return LocaleController.formatString("LastSeenContactsMinus", R.string.LastSeenContactsMinus, minus);
} else if (plus != 0) {
return LocaleController.formatString("LastSeenContactsPlus", R.string.LastSeenContactsPlus, plus);
}
}
} else if (type == 1 || type == -1 && plus > 0) {
if (plus == 0) {
return LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody);
} else {
return LocaleController.formatString("LastSeenNobodyPlus", R.string.LastSeenNobodyPlus, plus);
}
}
return "unknown";
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
private class ListAdapter extends BaseFragmentAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public boolean isEnabled(int i) {
return i == blockedRow || i == terminateSessionsRow || i == lastSeenRow && !ContactsController.getInstance().getLoadingLastSeenInfo() || i == deleteAccountRow && !ContactsController.getInstance().getLoadingDeleteInfo();
}
@Override
public int getCount() {
return rowCount;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new TextSettingsCell(mContext);
view.setBackgroundColor(0xffffffff);
}
TextSettingsCell textCell = (TextSettingsCell) view;
if (i == blockedRow) {
textCell.setText(LocaleController.getString("BlockedUsers", R.string.BlockedUsers), true);
} else if (i == terminateSessionsRow) {
textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
} else if (i == lastSeenRow) {
String value;
if (ContactsController.getInstance().getLoadingLastSeenInfo()) {
value = LocaleController.getString("Loading", R.string.Loading);
} else {
value = formatRulesString();
}
textCell.setTextAndValue(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen), value, false);
} else if (i == deleteAccountRow) {
String value;
if (ContactsController.getInstance().getLoadingDeleteInfo()) {
value = LocaleController.getString("Loading", R.string.Loading);
} else {
int ttl = ContactsController.getInstance().getDeleteAccountTTL();
if (ttl == 0) {
value = LocaleController.getString("DeleteAccountNever", R.string.DeleteAccountNever);
} else if (ttl <= 182) {
value = LocaleController.formatPluralString("Months", ttl / 30);
} else if (ttl == 365) {
value = LocaleController.formatPluralString("Years", ttl / 365);
} else {
value = LocaleController.formatPluralString("Days", ttl);
}
}
textCell.setTextAndValue(LocaleController.getString("DeleteAccountIfAwayFor", R.string.DeleteAccountIfAwayFor), value, false);
}
} else if (type == 1) {
if (view == null) {
view = new TextInfoPrivacyCell(mContext);
view.setBackgroundColor(0xffffffff);
}
if (i == deleteAccountDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("DeleteAccountHelp", R.string.DeleteAccountHelp));
view.setBackgroundResource(R.drawable.greydivider_bottom);
} else if (i == lastSeenDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("LastSeenHelp", R.string.LastSeenHelp));
view.setBackgroundResource(R.drawable.greydivider);
} else if (i == terminateSessionsDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
view.setBackgroundResource(R.drawable.greydivider);
}
} else if (type == 2) {
if (view == null) {
view = new HeaderCell(mContext);
view.setBackgroundColor(0xffffffff);
}
if (i == privacySectionRow) {
((HeaderCell) view).setText(LocaleController.getString("PrivacyTitle", R.string.PrivacyTitle));
} else if (i == securitySectionRow) {
((HeaderCell) view).setText(LocaleController.getString("SecurityTitle", R.string.SecurityTitle));
} else if (i == deleteAccountSectionRow) {
((HeaderCell) view).setText(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle));
}
}
return view;
}
@Override
public int getItemViewType(int i) {
if (i == lastSeenRow || i == blockedRow || i == deleteAccountRow || i == terminateSessionsRow) {
return 0;
} else if (i == deleteAccountDetailRow || i == lastSeenDetailRow || i == terminateSessionsDetailRow) {
return 1;
} else if (i == securitySectionRow || i == deleteAccountSectionRow || i == privacySectionRow) {
return 2;
}
return 0;
}
@Override
public int getViewTypeCount() {
return 3;
}
public class PrivacySettingsActivity extends BaseFragment {
@Override
public boolean isEmpty() {
return false;
}
}
}
......@@ -224,6 +224,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(final int id) {
......@@ -675,7 +678,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
FrameLayout.LayoutParams layoutParams;
if (listView != null) {
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
listView.setLayoutParams(layoutParams);
}
......@@ -694,7 +697,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (writeButton != null) {
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff);
writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE);
......@@ -877,6 +880,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
object.user_id = user_id;
object.thumb = object.imageReceiver.getBitmap();
object.size = -1;
object.radius = avatarImage.imageReceiver.getRoundRadius();
return object;
}
return null;
......@@ -1019,6 +1023,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
private void updateProfileData() {
if (avatarImage == null) {
return;
}
if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
TLRPC.FileLocation photo = null;
......@@ -1219,7 +1226,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
view = new TextCell(mContext);
}
TextCell textCell = (TextCell) view;
textCell.setTextColor(0xff000000);
textCell.setTextColor(0xff212121);
if (i == sharedMediaRow) {
String value;
......
......@@ -38,7 +38,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
......@@ -101,10 +100,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
private int settingsSectionRow2;
private int enableAnimationsRow;
private int notificationRow;
private int blockedRow;
private int backgroundRow;
private int languageRow;
private int terminateSessionsRow;
private int privacyRow;
private int mediaDownloadSection;
private int mediaDownloadSection2;
private int mobileDownloadRow;
......@@ -194,6 +192,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
UserConfig.saveConfig(true);
}
});
......@@ -214,10 +213,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
settingsSectionRow2 = rowCount++;
enableAnimationsRow = rowCount++;
notificationRow = rowCount++;
blockedRow = rowCount++;
privacyRow = rowCount++;
backgroundRow = rowCount++;
languageRow = rowCount++;
terminateSessionsRow = rowCount++;
mediaDownloadSection = rowCount++;
mediaDownloadSection2 = rowCount++;
mobileDownloadRow = rowCount++;
......@@ -268,6 +266,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
......@@ -303,7 +304,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
});
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);
......@@ -425,8 +425,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
} else if (i == notificationRow) {
presentFragment(new NotificationsSettingsActivity());
} else if (i == blockedRow) {
presentFragment(new BlockedUsersActivity());
} else if (i == backgroundRow) {
presentFragment(new WallpapersActivity());
} else if (i == askQuestionRow) {
......@@ -467,46 +465,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (listView != null) {
listView.invalidateViews();
}
} else if (i == terminateSessionsRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions));
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) {
TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations();
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (getParentActivity() == null) {
return;
}
if (error == null && response instanceof TLRPC.TL_boolTrue) {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), Toast.LENGTH_SHORT);
toast.show();
} else {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnknownError", R.string.UnknownError), Toast.LENGTH_SHORT);
toast.show();
}
}
});
UserConfig.registeredForPush = false;
UserConfig.registeredForInternalPush = false;
UserConfig.saveConfig(false);
MessagesController.getInstance().registerForPush(UserConfig.pushString);
ConnectionsManager.getInstance().initPushConnection();
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (i == privacyRow) {
presentFragment(new PrivacySettingsActivity());
} else if (i == languageRow) {
presentFragment(new LanguageSelectActivity());
} else if (i == switchBackendButtonRow) {
......@@ -745,6 +705,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
object.user_id = UserConfig.getClientUserId();
object.thumb = object.imageReceiver.getBitmap();
object.size = -1;
object.radius = avatarImage.imageReceiver.getRoundRadius();
return object;
}
}
......@@ -903,7 +864,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
FrameLayout.LayoutParams layoutParams;
if (listView != null) {
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight();
listView.setLayoutParams(layoutParams);
}
......@@ -921,7 +882,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm);
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff);
writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE);
......@@ -1021,8 +982,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override
public boolean isEnabled(int i) {
return i == textSizeRow || i == enableAnimationsRow || i == blockedRow || i == notificationRow || i == backgroundRow ||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == wifiDownloadRow ||
return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow ||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == privacyRow || i == wifiDownloadRow ||
i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow ||
i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow;
}
......@@ -1073,7 +1034,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
textCell.setTextAndValue(LocaleController.getString("TextSize", R.string.TextSize), String.format("%d", size), true);
} else if (i == languageRow) {
textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), true);
textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), false);
} else if (i == contactsSortRow) {
String value;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
......@@ -1088,8 +1049,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
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) {
......@@ -1098,8 +1057,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
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 == privacyRow) {
textCell.setText(LocaleController.getString("PrivacySettings", R.string.PrivacySettings), true);
} else if (i == switchBackendButtonRow) {
textCell.setText("Switch Backend", true);
} else if (i == telegramFaqRow) {
......@@ -1223,7 +1182,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
return 1;
} 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 || i == textSizeRow || i == languageRow || i == contactsSortRow) {
} else if (i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == privacyRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow || i == textSizeRow || i == languageRow || i == contactsSortRow) {
return 2;
} else if (i == versionRow) {
return 5;
......
......@@ -254,7 +254,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
});
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(1, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
menu.addItemWithWidth(1, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = inflater.inflate(R.layout.video_editor_layout, container, false);
originalSizeTextView = (TextView) fragmentView.findViewById(R.id.original_size);
......
......@@ -8,15 +8,10 @@
package org.telegram.ui.Views;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.os.Build;
import android.os.PowerManager;
import android.text.Editable;
import android.text.TextWatcher;
......@@ -48,10 +43,12 @@ import org.telegram.messenger.FileLog;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.ApplicationLoader;
import java.util.ArrayList;
public class ChatActivityEnterView implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate {
public static interface ChatActivityEnterViewDelegate {
......@@ -71,7 +68,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
private PowerManager.WakeLock mWakeLock;
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
private FrameLayout attachButton;
private Object runningAnimation;
private AnimatorSetProxy runningAnimation;
private AnimatorSetProxy runningAnimation2;
private int runningAnimationType;
private int keyboardHeight;
......@@ -134,6 +132,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
messsageEditText.setHint(LocaleController.getString("TypeMessage", R.string.TypeMessage));
attachButton = (FrameLayout) containerView.findViewById(R.id.chat_attach_button);
if (attachButton != null) {
ViewProxy.setPivotX(attachButton, AndroidUtilities.dp(48));
}
sendButton = (ImageButton) containerView.findViewById(R.id.chat_send_button);
sendButton.setVisibility(View.INVISIBLE);
......@@ -224,8 +225,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
recordingAudio = false;
updateAudioRecordIntefrace();
}
if (android.os.Build.VERSION.SDK_INT > 13) {
x = x + audioSendButton.getX();
x = x + ViewProxy.getX(audioSendButton);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
if (startedDraggingX != -1) {
float dist = (x - startedDraggingX);
......@@ -237,9 +238,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
} else if (alpha < 0) {
alpha = 0;
}
slideText.setAlpha(alpha);
ViewProxy.setAlpha(slideText, alpha);
}
if (x <= slideText.getX() + slideText.getWidth() + AndroidUtilities.dp(30)) {
if (x <= ViewProxy.getX(slideText) + slideText.getWidth() + AndroidUtilities.dp(30)) {
if (startedDraggingX == -1) {
startedDraggingX = x;
distCanMove = (recordPanel.getMeasuredWidth() - slideText.getMeasuredWidth() - AndroidUtilities.dp(48)) / 2.0f;
......@@ -253,11 +254,10 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
if (params.leftMargin > AndroidUtilities.dp(30)) {
params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params);
slideText.setAlpha(1);
ViewProxy.setAlpha(slideText, 1);
startedDraggingX = -1;
}
}
}
view.onTouchEvent(motionEvent);
return true;
}
......@@ -349,46 +349,63 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
return src;
}
private void checkSendButton(boolean animated) {
private void checkSendButton(final boolean animated) {
String message = getTrimmedString(messsageEditText.getText().toString());
if (message.length() > 0) {
if (audioSendButton.getVisibility() == View.VISIBLE) {
if (Build.VERSION.SDK_INT >= 11 && animated) {
if (animated) {
if (runningAnimationType == 1) {
return;
}
if (runningAnimation != null) {
((AnimatorSet) runningAnimation).cancel();
runningAnimation.cancel();
runningAnimation = null;
}
if (runningAnimation2 != null) {
runningAnimation2.cancel();
runningAnimation2 = null;
}
sendButton.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet();
runningAnimation = animatorSet;
runningAnimationType = 1;
ArrayList<Animator> animators = new ArrayList<Animator>();
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleX", 0.1f));
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleY", 0.1f));
animators.add(ObjectAnimator.ofFloat(audioSendButton, "alpha", 0.0f));
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleX", 1.0f));
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleY", 1.0f));
animators.add(ObjectAnimator.ofFloat(sendButton, "alpha", 1.0f));
if (attachButton != null) {
animators.add(ObjectAnimator.ofFloat(attachButton, "alpha", 0.0f));
animators.add(ObjectAnimator.ofFloat(attachButton, "translationX", AndroidUtilities.dp(48)));
runningAnimation2 = new AnimatorSetProxy();
runningAnimation2.playTogether(
ObjectAnimatorProxy.ofFloat(attachButton, "alpha", 0.0f),
ObjectAnimatorProxy.ofFloat(attachButton, "scaleX", 0.0f)
);
runningAnimation2.setDuration(100);
runningAnimation2.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animation) {
if (runningAnimation2.equals(animation)) {
attachButton.setVisibility(View.GONE);
}
}
});
runningAnimation2.start();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(6);
layoutParams.rightMargin = AndroidUtilities.dp(2);
messsageEditText.setLayoutParams(layoutParams);
}
animatorSet.playTogether(animators);
animatorSet.setDuration(200);
animatorSet.addListener(new AnimatorListenerAdapter() {
sendButton.setVisibility(View.VISIBLE);
runningAnimation = new AnimatorSetProxy();
runningAnimationType = 1;
runningAnimation.playTogether(
ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 0.1f),
ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 0.1f),
ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 0.0f),
ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 1.0f),
ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 1.0f),
ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 1.0f)
);
runningAnimation.setDuration(150);
runningAnimation.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation == runningAnimation) {
public void onAnimationEnd(Object animation) {
if (runningAnimation.equals(animation)) {
sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE);
runningAnimation = null;
......@@ -396,16 +413,14 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
}
}
});
animatorSet.start();
runningAnimation.start();
} else {
if (Build.VERSION.SDK_INT >= 11) {
audioSendButton.setScaleX(0.1f);
audioSendButton.setScaleY(0.1f);
audioSendButton.setAlpha(0.0f);
sendButton.setScaleX(1.0f);
sendButton.setScaleY(1.0f);
sendButton.setAlpha(1.0f);
}
ViewProxy.setScaleX(audioSendButton, 0.1f);
ViewProxy.setScaleY(audioSendButton, 0.1f);
ViewProxy.setAlpha(audioSendButton, 0.0f);
ViewProxy.setScaleX(sendButton, 1.0f);
ViewProxy.setScaleY(sendButton, 1.0f);
ViewProxy.setAlpha(sendButton, 1.0f);
sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE);
if (attachButton != null) {
......@@ -414,43 +429,53 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
}
}
} else if (sendButton.getVisibility() == View.VISIBLE) {
if (Build.VERSION.SDK_INT >= 11 && animated) {
if (animated) {
if (runningAnimationType == 2) {
return;
}
if (runningAnimation != null) {
((AnimatorSet) runningAnimation).cancel();
runningAnimation.cancel();
runningAnimation = null;
}
if (runningAnimation2 != null) {
runningAnimation2.cancel();
runningAnimation2 = null;
}
audioSendButton.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet();
runningAnimation = animatorSet;
runningAnimationType = 2;
ArrayList<Animator> animators = new ArrayList<Animator>();
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleX", 0.1f));
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleY", 0.1f));
animators.add(ObjectAnimator.ofFloat(sendButton, "alpha", 0.0f));
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleX", 1.0f));
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleY", 1.0f));
animators.add(ObjectAnimator.ofFloat(audioSendButton, "alpha", 1.0f));
if (attachButton != null) {
animators.add(ObjectAnimator.ofFloat(attachButton, "alpha", 1.0f));
animators.add(ObjectAnimator.ofFloat(attachButton, "translationX", 0.0f));
attachButton.setVisibility(View.VISIBLE);
runningAnimation2 = new AnimatorSetProxy();
runningAnimation2.playTogether(
ObjectAnimatorProxy.ofFloat(attachButton, "alpha", 1.0f),
ObjectAnimatorProxy.ofFloat(attachButton, "scaleX", 1.0f)
);
runningAnimation2.setDuration(100);
runningAnimation2.start();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
layoutParams.rightMargin = AndroidUtilities.dp(54);
layoutParams.rightMargin = AndroidUtilities.dp(2);
messsageEditText.setLayoutParams(layoutParams);
}
animatorSet.playTogether(animators);
animatorSet.setDuration(200);
animatorSet.addListener(new AnimatorListenerAdapter() {
audioSendButton.setVisibility(View.VISIBLE);
runningAnimation = new AnimatorSetProxy();
runningAnimationType = 2;
runningAnimation.playTogether(
ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 0.1f),
ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 0.1f),
ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 0.0f),
ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 1.0f),
ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 1.0f),
ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 1.0f)
);
runningAnimation.setDuration(150);
runningAnimation.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation == runningAnimation) {
public void onAnimationEnd(Object animation) {
if (runningAnimation.equals(animation)) {
sendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.VISIBLE);
runningAnimation = null;
......@@ -458,16 +483,14 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
}
}
});
animatorSet.start();
runningAnimation.start();
} else {
if (Build.VERSION.SDK_INT >= 11) {
sendButton.setScaleX(0.1f);
sendButton.setScaleY(0.1f);
sendButton.setAlpha(0.0f);
audioSendButton.setScaleX(1.0f);
audioSendButton.setScaleY(1.0f);
audioSendButton.setAlpha(1.0f);
}
ViewProxy.setScaleX(sendButton, 0.1f);
ViewProxy.setScaleY(sendButton, 0.1f);
ViewProxy.setAlpha(sendButton, 0.0f);
ViewProxy.setScaleX(audioSendButton, 1.0f);
ViewProxy.setScaleY(audioSendButton, 1.0f);
ViewProxy.setAlpha(audioSendButton, 1.0f);
sendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.VISIBLE);
if (attachButton != null) {
......@@ -493,31 +516,21 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
recordPanel.setVisibility(View.VISIBLE);
recordTimeText.setText("00:00");
lastTimeString = null;
if (android.os.Build.VERSION.SDK_INT > 13) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params);
slideText.setAlpha(1);
ViewProxy.setAlpha(slideText, 1);
recordPanel.setX(AndroidUtilities.displaySize.x);
recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
ObjectAnimatorProxy animatorProxy = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", 0).setDuration(300);
animatorProxy.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
recordPanel.setX(0);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
}).setDuration(300).translationX(0).start();
public void onAnimationEnd(Object animator) {
ViewProxy.setX(recordPanel, 0);
}
});
animatorProxy.setInterpolator(new AccelerateDecelerateInterpolator());
animatorProxy.start();
} else {
if (mWakeLock != null) {
try {
......@@ -528,33 +541,20 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
}
}
AndroidUtilities.unlockOrientation(parentActivity);
if (android.os.Build.VERSION.SDK_INT > 13) {
recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
ObjectAnimatorProxy animatorProxy = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", AndroidUtilities.displaySize.x).setDuration(300);
animatorProxy.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animator) {
public void onAnimationEnd(Object animator) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params);
slideText.setAlpha(1);
recordPanel.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
}).setDuration(300).translationX(AndroidUtilities.displaySize.x).start();
} else {
ViewProxy.setAlpha(slideText, 1);
recordPanel.setVisibility(View.GONE);
}
});
animatorProxy.setInterpolator(new AccelerateDecelerateInterpolator());
animatorProxy.start();
}
}
......
......@@ -10,9 +10,13 @@ package org.telegram.ui.Views;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.view.View;
import org.telegram.messenger.FileLog;
......@@ -28,6 +32,14 @@ public class ClippingImageView extends View {
private Bitmap bmp;
private onDrawListener drawListener;
private boolean needRadius;
private int radius;
private BitmapShader bitmapShader;
private Paint roundPaint;
private RectF roundRect;
private RectF bitmapRect;
private Matrix shaderMatrix;
public static interface onDrawListener {
public abstract void onDraw();
}
......@@ -59,6 +71,10 @@ public class ClippingImageView extends View {
return clipTop;
}
public int getRadius() {
return radius;
}
public void onDraw(Canvas canvas) {
if (getVisibility() == GONE || getVisibility() == INVISIBLE) {
return;
......@@ -69,13 +85,21 @@ public class ClippingImageView extends View {
drawListener.onDraw();
}
canvas.save();
if (needRadius) {
roundRect.set(0, 0, getWidth(), getHeight());
shaderMatrix.reset();
shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL);
bitmapShader.setLocalMatrix(shaderMatrix);
canvas.drawRoundRect(roundRect, radius, radius, roundPaint);
} else {
canvas.clipRect(clipLeft / scaleY, clipTop / scaleY, getWidth() - clipRight / scaleY, getHeight() - clipBottom / scaleY);
drawRect.set(0, 0, getWidth(), getHeight());
try {
canvas.drawBitmap(this.bmp, null, drawRect, this.paint);
canvas.drawBitmap(bmp, null, drawRect, paint);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
canvas.restore();
}
}
......@@ -114,10 +138,27 @@ public class ClippingImageView extends View {
public void setImageBitmap(Bitmap bitmap) {
bmp = bitmap;
if (bitmap != null && needRadius) {
roundRect = new RectF();
shaderMatrix = new Matrix();
bitmapRect = new RectF();
bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
roundPaint.setShader(bitmapShader);
}
invalidate();
}
public void setOnDrawListener(onDrawListener listener) {
drawListener = listener;
}
public void setNeedRadius(boolean value) {
needRadius = value;
}
public void setRadius(int value) {
radius = value;
}
}
......@@ -10,20 +10,19 @@ package org.telegram.ui.Views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
public class TimerButton extends View {
public class TimerDrawable extends Drawable {
private static Drawable emptyTimerDrawable;
private static Drawable timerDrawable;
......@@ -33,32 +32,15 @@ public class TimerButton extends View {
private int timeHeight = 0;
private int time = 0;
private void init() {
public TimerDrawable(Context context) {
if (emptyTimerDrawable == null) {
emptyTimerDrawable = getResources().getDrawable(R.drawable.header_timer);
timerDrawable = getResources().getDrawable(R.drawable.header_timer2);
emptyTimerDrawable = context.getResources().getDrawable(R.drawable.header_timer);
timerDrawable = context.getResources().getDrawable(R.drawable.header_timer2);
timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
timePaint.setTextSize(AndroidUtilities.dp(10));
timePaint.setColor(0xffd7e8f7);
timePaint.setTypeface(Typeface.DEFAULT_BOLD);
}
setBackgroundResource(R.drawable.bar_selector);
}
public TimerButton(Context context) {
super(context);
init();
}
public TimerButton(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TimerButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public void setTime(int value) {
......@@ -103,13 +85,13 @@ public class TimerButton extends View {
FileLog.e("tmessages", e);
}
invalidate();
invalidateSelf();
}
@Override
protected void onDraw(Canvas canvas) {
int width = getMeasuredWidth();
int height = getMeasuredHeight();
public void draw(Canvas canvas) {
int width = canvas.getWidth();
int height = canvas.getHeight();
Drawable drawable = null;
if (time == 0) {
drawable = timerDrawable;
......@@ -127,4 +109,29 @@ public class TimerButton extends View {
timeLayout.draw(canvas);
}
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return 0;
}
@Override
public int getIntrinsicWidth() {
return -1;
}
@Override
public int getIntrinsicHeight() {
return -1;
}
}
......@@ -155,7 +155,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56));
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
listAdapter = new ListAdapter(getParentActivity());
......
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="-100%"
android:toYDelta="0"
android:duration="200"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="0%"
android:toYDelta="-100%"
android:duration="200"/>
</set>
\ No newline at end of file
TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png

652 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png

227 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png

444 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png

373 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png

325 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png

198 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png

501 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png

207 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png

330 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png

278 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png

253 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png

177 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png

764 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png

284 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png

651 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png

456 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png

414 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png

200 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png

1.13 KB | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png

356 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png

673 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png

620 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png

589 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png

226 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png
TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/msg_in_selected" />
<item android:state_checked="true" android:drawable="@drawable/msg_in_selected" />
<item android:state_pressed="true" android:drawable="@drawable/msg_in_selected" />
<item android:drawable="@drawable/msg_in" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/msg_out_selected" />
<item android:state_checked="true" android:drawable="@drawable/msg_out_selected" />
<item android:state_pressed="true" android:drawable="@drawable/msg_out_selected" />
<item android:drawable="@drawable/msg_out"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/fastscroll_thumb_pressed_holo"/>
<item android:drawable="@drawable/fastscroll_thumb_default_holo"/>
</selector>
\ No newline at end of file
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#0f000000" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="#0f000000" />
</shape>
</item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="#0f000000" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#f2f2f2" />
</shape>
</item>
</selector>
\ No newline at end of file
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#f2f5f7" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="#f2f5f7" />
</shape>
</item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="#f2f5f7" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#ffffffff" />
</shape>
</item>
</selector>
\ No newline at end of file
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="11dp"
android:insetRight="11dp">
<shape android:shape="rectangle">
<solid android:color="@color/divider"/>
</shape>
</inset>
\ No newline at end of file
<inset
xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<solid android:color="@color/divider"/>
</shape>
</inset>
\ No newline at end of file
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#802a2a2a" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip android:clipOrientation="horizontal" android:gravity="top|left">
<shape>
<solid android:color="#8cd1fc" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#802a2a2a" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip android:clipOrientation="horizontal" android:gravity="top|left">
<shape>
<solid android:color="#ffffff" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#802a2a2a" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip android:clipOrientation="horizontal" android:gravity="top|left">
<shape>
<solid android:color="#39b0dd" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical">
<LinearLayout
android:gravity="center_vertical|right"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<LinearLayout
android:layout_gravity="center_vertical|left"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="13dp"
android:layout_marginBottom="1dp">
<TextView
android:textSize="21dp"
android:textColor="#333333"
android:ellipsize="end"
android:id="@+id/settings_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:gravity="right"
android:layout_gravity="right"/>
<TextView
android:textSize="14dp"
android:textColor="#999999"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:id="@+id/settings_online"
android:gravity="right"
android:layout_gravity="right"/>
</LinearLayout>
<org.telegram.ui.Views.BackupImageView
android:id="@+id/settings_avatar_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="right"/>
</LinearLayout>
<EditText
android:textSize="19dp"
android:textColorHint="#a3a3a3"
android:layout_gravity="center_vertical"
android:id="@+id/first_name_field"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:lines="1"
android:singleLine="true"
android:inputType="textCapSentences|textAutoCorrect"
android:imeOptions="actionNext"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:gravity="right"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
<EditText
android:textSize="19dp"
android:textColorHint="#a3a3a3"
android:layout_gravity="center_vertical"
android:id="@+id/last_name_field"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:lines="1"
android:singleLine="true"
android:inputType="textCapSentences|textAutoCorrect"
android:imeOptions="actionDone"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:gravity="right"
android:textCursorDrawable="@null"
android:textColor="#000000"
android:layout_marginBottom="16dp"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<!--
~ This is the source code of Telegram for Android v. 1.3.2.
~ 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/HLRelativeLayout1"
android:layout_width="match_parent"
android:layout_height="64dp"
android:paddingLeft="13dp"
android:paddingRight="13dp">
<TextView
android:id="@+id/docs_item_type"
android:layout_width="55dp"
android:layout_height="42dp"
android:layout_marginTop="11dp"
android:background="#1A808080"
android:ellipsize="marquee"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textColor="#919191"
android:textSize="16dp"
android:textStyle="bold"
android:layout_gravity="top|right"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="62dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="66dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:layout_gravity="top|right">
<TextView
android:id="@+id/docs_item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="TextView"
android:textColor="#000"
android:textSize="18dp"
android:gravity="right"
android:layout_gravity="top|right"/>
<TextView
android:id="@+id/docs_item_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="marquee"
android:singleLine="true"
android:text="TextView"
android:textColor="#a6a6a6"
android:textSize="16dp"
android:gravity="right"
android:layout_gravity="top|right"/>
</LinearLayout>
<org.telegram.ui.Views.BackupImageView
android:id="@+id/docs_item_thumb"
android:layout_width="55dp"
android:layout_height="42dp"
android:layout_marginTop="11dp"
android:layout_gravity="top|right"/>
<View
android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>
\ No newline at end of file
<!--
~ 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.
-->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/launch_layout">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/cats"
android:scaleType="centerCrop"
android:id="@+id/launch_background"/>
<LinearLayout
android:layout_width="320dp"
android:layout_height="wrap_content"
android:id="@+id/launch_button_layout"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="308dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/btnshadow"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/new_group_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingRight="17dp"
android:background="@drawable/launch_button_states"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffd6dee4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/new_secret_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingRight="17dp"
android:background="@drawable/launch_button_states"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffd6dee4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/new_broadcast_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingRight="17dp"
android:background="@drawable/launch_button_states"/>
</LinearLayout>
<LinearLayout
android:layout_width="308dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/btnshadow"
android:layout_gravity="center"
android:layout_marginTop="18dp">
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/contacts_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingRight="17dp"
android:background="@drawable/launch_button_states"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffd6dee4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/settings_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingRight="17dp"
android:background="@drawable/launch_button_states"/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="#40295274"
android:id="@+id/shadow_tablet_side"/>
<FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/shadow_tablet"
android:background="#7F000000"
android:visibility="gone"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<org.telegram.ui.Views.TimerButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="48dp"
android:id="@+id/chat_timer"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<org.telegram.ui.Views.BackupImageView
android:layout_height="48dp"
android:layout_width="48dp"
android:id="@+id/chat_avatar_image"/>
</RelativeLayout>
\ No newline at end of file
......@@ -19,7 +19,7 @@
android:paddingBottom="2dp"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:textSize="14dp"
android:textSize="16dp"
android:id="@+id/searchEmptyView"
android:layout_gravity="center"/>
......@@ -77,32 +77,6 @@
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="48dp"
android:id="@+id/top_panel">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:id="@+id/top_panel_text"
android:textAllCaps="true"
android:textSize="12dp"
android:textStyle="bold"
android:textColor="#ffffff"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="centerInside"
android:layout_marginRight="4dp"
android:layout_gravity="right|center"
android:id="@+id/top_plane_close"
android:clickable="true"/>
</FrameLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
......@@ -142,8 +116,8 @@
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="16384"
android:layout_marginLeft="54dp"
android:layout_marginRight="54dp"
android:layout_marginLeft="52dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="4dp"
android:paddingBottom="10dp"
android:paddingTop="4dp"
......
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/settings_avatar_image"
android:layout_width="64dp"
android:layout_height="64dp"/>
<LinearLayout
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_marginBottom="1dp">
<TextView
android:textSize="21dp"
android:textColor="#333333"
android:ellipsize="end"
android:id="@+id/settings_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"/>
<TextView
android:textSize="14dp"
android:textColor="#999999"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:id="@+id/settings_online"/>
</LinearLayout>
</LinearLayout>
<EditText
android:textSize="19dp"
android:textColorHint="#a3a3a3"
android:layout_gravity="center_vertical"
android:id="@+id/first_name_field"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:lines="1"
android:singleLine="true"
android:inputType="textCapSentences|textAutoCorrect"
android:imeOptions="actionNext"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
<EditText
android:textSize="19dp"
android:textColorHint="#a3a3a3"
android:layout_gravity="center_vertical"
android:id="@+id/last_name_field"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:lines="1"
android:singleLine="true"
android:inputType="textCapSentences|textAutoCorrect"
android:imeOptions="actionDone"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:textCursorDrawable="@null"
android:textColor="#000000"
android:layout_marginBottom="16dp"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/HLRelativeLayout1"
android:layout_width="match_parent"
android:layout_height="64dp"
android:paddingLeft="13dp"
android:paddingRight="13dp">
<TextView
android:id="@+id/docs_item_type"
android:layout_width="55dp"
android:layout_height="42dp"
android:layout_marginTop="11dp"
android:background="#1A808080"
android:ellipsize="marquee"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textColor="#919191"
android:textSize="16dp"
android:textStyle="bold"
android:layout_gravity="top|left"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="62dp"
android:layout_marginRight="7dp"
android:layout_marginLeft="66dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:layout_gravity="top|left">
<TextView
android:id="@+id/docs_item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="TextView"
android:textColor="#000"
android:textSize="18dp"
android:layout_gravity="top|left"/>
<TextView
android:id="@+id/docs_item_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="marquee"
android:singleLine="true"
android:text="TextView"
android:textColor="#a6a6a6"
android:textSize="16dp"
android:layout_gravity="top|left"/>
</LinearLayout>
<org.telegram.ui.Views.BackupImageView
android:id="@+id/docs_item_thumb"
android:layout_width="55dp"
android:layout_height="42dp"
android:layout_marginTop="11dp"
android:layout_gravity="top|left"/>
<View
android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>
\ No newline at end of file
......@@ -19,7 +19,7 @@
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:textSize="20dp"
android:id="@+id/searchEmptyView"
android:visibility="gone"
android:layout_gravity="top"/>
......
<FrameLayout
android:layout_width="1px"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
</FrameLayout>
\ No newline at end of file
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/top_layout"
android:layout_gravity="top">
<FrameLayout
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_marginLeft="16dp"
android:layout_gravity="top">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/settings_avatar_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
<EditText
android:textSize="18dp"
android:textColorHint="#a6a6a6"
android:id="@+id/bubble_input_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="96dp"
android:layout_marginRight="16dp"
android:minHeight="52dp"
android:maxLines="4"
android:paddingTop="0dp"
android:layout_marginTop="0dp"
android:gravity="left|center_vertical"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:layout_gravity="center_vertical"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.telegram.ui.Views.PinnedHeaderListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"
android:paddingBottom="16dp"
android:scrollbars="none"/>
</FrameLayout>
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="13dp"
android:paddingRight="13dp"
android:dividerHeight="0dp"
android:divider="@null"
android:scrollbars="none"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="invisible"
android:layout_gravity="top"/>
</RelativeLayout>
\ No newline at end of file
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/launch_layout">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/cats"
android:scaleType="centerCrop"
android:id="@+id/launch_background"/>
<LinearLayout
android:layout_width="320dp"
android:layout_height="wrap_content"
android:id="@+id/launch_button_layout"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="308dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/btnshadow"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/new_group_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingLeft="17dp"
android:background="@drawable/launch_button_states"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffd6dee4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/new_secret_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingLeft="17dp"
android:background="@drawable/launch_button_states"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffd6dee4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/new_broadcast_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingLeft="17dp"
android:background="@drawable/launch_button_states"/>
</LinearLayout>
<LinearLayout
android:layout_width="308dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/btnshadow"
android:layout_gravity="center"
android:layout_marginTop="18dp">
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/contacts_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingLeft="17dp"
android:background="@drawable/launch_button_states"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffd6dee4"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/settings_button"
android:textColor="#ff54759e"
android:gravity="center_vertical"
android:textSize="20dp"
android:paddingLeft="17dp"
android:background="@drawable/launch_button_states"/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="#40295274"
android:id="@+id/shadow_tablet_side"/>
<FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/shadow_tablet"
android:background="#7F000000"
android:visibility="gone"/>
</RelativeLayout>
\ No newline at end of file
......@@ -25,7 +25,7 @@
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:textSize="20dp"
android:id="@+id/searchEmptyView"
android:visibility="gone"/>
......
......@@ -14,18 +14,33 @@
android:dividerHeight="0px"
android:animationCache="false"/>
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/search_empty_view"
android:orientation="vertical"
android:gravity="center"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="gone"/>
android:textSize="20dp"
android:id="@+id/search_empty_text"
android:layout_weight="1"/>
<FrameLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:id="@+id/list_empty_view"
android:orientation="vertical"
android:gravity="center"
......@@ -33,15 +48,15 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:textColor="#959595"
android:gravity="center"
android:textSize="24dp"
android:textSize="20dp"
android:id="@+id/list_empty_view_text1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:textColor="#959595"
android:gravity="center"
android:textSize="15dp"
......
......@@ -30,7 +30,7 @@
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:textSize="20dp"
android:id="@+id/searchEmptyView"
android:visibility="gone"
android:layout_marginBottom="48dp"/>
......
......@@ -19,15 +19,20 @@
android:layout_marginRight="12dp"
android:id="@+id/popup_container">
<RelativeLayout
android:layout_width="match_parent"
<LinearLayout
android:layout_height="wrap_content"
android:id="@+id/chat_compose_panel"
android:background="@drawable/compose_panel"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="bottom"
android:layout_alignParentBottom="true">
android:id="@+id/chat_compose_panel"
android:background="@drawable/compose_panel"
android:orientation="horizontal">
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView
android:src="@drawable/ic_msg_panel_smiles"
......@@ -35,43 +40,29 @@
android:layout_height="48dp"
android:layout_marginTop="2dp"
android:paddingTop="1dp"
android:scaleType="centerInside"
android:paddingLeft="4dp"
android:id="@+id/chat_smile_button"
android:layout_alignBottom="@+id/chat_text_edit"/>
<ImageButton
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="2dp"
android:scaleType="centerInside"
android:id="@+id/chat_send_button"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/chat_text_edit"
android:enabled="false"
android:src="@drawable/ic_send"
android:background="@android:color/transparent"/>
android:layout_gravity="bottom"
android:id="@+id/chat_smile_button"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="@+id/chat_text_edit"
android:layout_toRightOf="@id/chat_smile_button"
android:layout_toLeftOf="@id/chat_send_button"
android:layout_marginTop="2dp"
android:maxLines="2"
android:minHeight="48dp"
android:textSize="18dp"
android:textColorHint="#909090"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textMultiLine"
android:layout_alignParentTop="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:maxLength="16384"
android:layout_marginLeft="52dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="4dp"
android:paddingBottom="10dp"
android:paddingTop="4dp"
android:maxLength="16384"
android:textCursorDrawable="@null"
android:textColor="#000000"/>
......@@ -79,7 +70,7 @@
android:layout_height="48dp"
android:layout_width="fill_parent"
android:layout_marginTop="2dp"
android:layout_marginRight="48dp"
android:layout_gravity="bottom"
android:background="#ffffff"
android:id="@+id/record_panel"
android:visibility="gone">
......@@ -139,20 +130,36 @@
</org.telegram.ui.Views.FrameLayoutFixed>
</FrameLayout>
<FrameLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:layout_marginTop="2dp">
<ImageButton
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="2dp"
android:scaleType="centerInside"
android:id="@+id/chat_audio_send_button"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/chat_text_edit"
android:enabled="false"
android:src="@drawable/mic_button_states"
android:paddingRight="4dp"
android:background="@android:color/white"/>
</RelativeLayout>
<ImageButton
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="centerInside"
android:id="@+id/chat_send_button"
android:enabled="false"
android:src="@drawable/ic_send"
android:background="@android:color/transparent"/>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
......
......@@ -19,6 +19,7 @@
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#ff000000"
android:textColorLink="#ff000000"
android:id="@+id/message_text"
android:gravity="center"
android:layout_gravity="center"/>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_tab_pressed">#6633B5E5</color>
<color name="chat_background_color">#ffd6e4ef</color>
<color name="gallery_background_color">#ff000000</color>
<color name="settings_background_color">#ffffffff</color>
<color name="divider">#dcdcdc</color>
<color name="header">#ff54759e</color>
</resources>
\ No newline at end of file
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
......@@ -28,16 +28,13 @@
<string name="LastName">Last name (optional)</string>
<string name="CancelRegistration">Cancel registration</string>
<!--chats view-->
<string name="Chats">Chats</string>
<string name="Search">Search</string>
<string name="NewMessages">New messages</string>
<string name="Settings">Settings</string>
<string name="Contacts">Contacts</string>
<string name="NewGroup">New Group</string>
<string name="Yesterday">yesterday</string>
<string name="NoResult">No results</string>
<string name="NoChats">No chats yet...</string>
<string name="NoChatsHelp">Start messaging by pressing the\ncompose button in the top right corner\nor tap the menu button for more options.</string>
<string name="NoChatsHelp">Start messaging by pressing the\nnew message button in the bottom right corner\nor tap the menu button for more options.</string>
<string name="WaitingForNetwork">Waiting for network...</string>
<string name="Connecting">Connecting...</string>
<string name="Updating">Updating...</string>
......@@ -47,16 +44,15 @@
<string name="EncryptionProcessing">Exchanging encryption keys...</string>
<string name="EncryptedChatStartedOutgoing">%s joined your secret chat.</string>
<string name="EncryptedChatStartedIncoming">You joined the secret chat.</string>
<string name="ClearHistory">Clear History</string>
<string name="ClearHistory">Clear history</string>
<string name="DeleteChat">Delete and exit</string>
<string name="DeleteChatUser">Delete chat</string>
<string name="HiddenName">Hidden Name</string>
<string name="SelectChat">Select Chat</string>
<string name="PhotoTip">Tap and hold to view</string>
<string name="CompatibilityChat">%1$s is using an older version of Telegram, so secret photos will be shown in compatibility mode.\n\nOnce %2$s updates Telegram, photos with timers for 1 minute or less will start working in \'Tap and hold to view\' mode, and you will be notified whenever the other party takes a screenshot.</string>
<string name="SearchConversations">CONVERSATIONS</string>
<string name="SearchMessages">MESSAGES</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
......@@ -75,10 +71,10 @@
<string name="ExternalStorage">External Storage</string>
<string name="SystemRoot">System Root</string>
<string name="SdCard">SD Card</string>
<string name="Folder">Folder</string>
<!--chat view-->
<string name="Invisible">invisible</string>
<string name="Typing">typing...</string>
<string name="Attach">Attach</string>
<string name="IsTyping">is typing...</string>
<string name="AreTyping">are typing...</string>
<string name="GotAQuestion">Got a question\nabout Telegram?</string>
......@@ -88,18 +84,13 @@
<string name="ChatVideo">Video</string>
<string name="ChatDocument">Document</string>
<string name="NoMessages">No messages here yet...</string>
<string name="ViewPhoto">View Photo</string>
<string name="ViewLocation">View Location</string>
<string name="ViewVideo">Play Video</string>
<string name="ForwardedMessage">Forwarded message</string>
<string name="From">From</string>
<string name="NoRecent">No recent</string>
<string name="Message">Message</string>
<string name="TypeMessage">Type message</string>
<string name="DOWNLOAD">Download</string>
<string name="Selected">Selected: %d</string>
<string name="ShareMyContactInfo">SHARE MY CONTACT INFO</string>
<string name="AddToContacts">ADD TO CONTACTS</string>
<string name="TypeMessage">Message</string>
<string name="ShareMyContactInfo">Share my contact</string>
<string name="AddToContacts">Add to contacts</string>
<string name="EncryptedPlaceholderTitleIncoming">%s invited you to join a secret chat.</string>
<string name="EncryptedPlaceholderTitleOutgoing">You have invited %s to join a secret chat.</string>
<string name="EncryptedDescriptionTitle">Secret chats:</string>
......@@ -116,8 +107,6 @@
<string name="ApplyLocalizationFile">Apply localization file</string>
<string name="UnsupportedAttachment">Unsupported attachment</string>
<!--notification-->
<string name="EncryptedChatRequested">Secret chat requested</string>
<string name="EncryptedChatAccepted">Secret chat started</string>
<string name="MessageLifetimeChanged">%1$s set the self-destruct timer to %2$s</string>
<string name="MessageLifetimeChangedOutgoing">You set the self-destruct timer to %1$s</string>
<string name="MessageLifetimeRemoved">%1$s disabled the self-destruct timer</string>
......@@ -160,21 +149,21 @@
<string name="TodayAt">today at</string>
<string name="YesterdayAt">yesterday at</string>
<string name="Online">online</string>
<string name="Offline">offline</string>
<string name="LastSeen">last seen</string>
<string name="LastSeenDate">last seen</string>
<string name="InviteFriends">Invite Friends</string>
<string name="GlobalSearch">GLOBAL SEARCH</string>
<string name="Lately">last seen recently</string>
<string name="WithinAWeek">last seen within a week</string>
<string name="WithinAMonth">last seen within a month</string>
<string name="ALongTimeAgo">last seen a long time ago</string>
<!--group create view-->
<string name="SendMessageTo">Send message to...</string>
<string name="EnterGroupNamePlaceholder">Enter group name</string>
<string name="GroupName">Group name</string>
<string name="AllContacts">ALL CONTACTS</string>
<string name="MembersCount">%1$d/%2$d members</string>
<!--group info view-->
<string name="EnterGroupNameTitle">Enter group name</string>
<string name="SharedMedia">Shared Media</string>
<string name="GroupInfo">Group Info</string>
<string name="SETTINGS">Settings</string>
<string name="AddMember">Add member</string>
<string name="DeleteAndExit">Delete and leave group</string>
......@@ -192,11 +181,8 @@
<string name="PhoneWork">Work</string>
<string name="PhoneOther">Other</string>
<string name="PhoneMain">Main</string>
<string name="ContactInfo">Contact Info</string>
<string name="PHONE">PHONE</string>
<string name="StartEncryptedChat">Start Secret Chat</string>
<string name="CreateEncryptedChatError">An error occurred.</string>
<string name="SecretTitle">Secret Chat</string>
<string name="EncryptionKey">Encryption Key</string>
<string name="MessageLifetime">Self-Destruct Timer</string>
<string name="ShortMessageLifetimeForever">Off</string>
......@@ -240,9 +226,7 @@
<string name="UndoAllCustom">Undo all custom notification settings for all your contacts and groups</string>
<string name="NotificationsAndSounds">Notifications and Sounds</string>
<string name="BlockedUsers">Blocked Users</string>
<string name="SaveIncomingPhotos">Save Incoming Photos</string>
<string name="LogOut">Log out</string>
<string name="YourFirstNameAndLastName">YOUR FIRST AND LAST NAME</string>
<string name="NoSound">No sound</string>
<string name="Default">Default</string>
<string name="Support">Support</string>
......@@ -266,7 +250,6 @@
<string name="NotificationsServiceDisableInfo">If Google Play Services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
<string name="SortBy">Sort By</string>
<string name="ImportContacts">Import Contacts</string>
<string name="WiFiOnly">Via WiFi only</string>
<string name="SortFirstName">First name</string>
<string name="SortLastName">Last name</string>
<string name="LedColor">LED Color</string>
......@@ -289,9 +272,7 @@
<string name="EditName">Edit name</string>
<!--media view-->
<string name="NoMedia">No shared media yet</string>
<string name="CancelDownload">Cancel Download</string>
<!--map view-->
<string name="MyLocation">My location</string>
<string name="Map">Map</string>
<string name="Satellite">Satellite</string>
<string name="Hybrid">Hybrid</string>
......@@ -325,6 +306,8 @@
<string name="DeleteAccountNowConfirmation">Delete your account?</string>
<string name="DeleteAccountNever">Never</string>
<string name="LastSeenHelp">Change who can see your Last Seen time.</string>
<string name="LastSeenTitle">Who can see your Last Seen time?</string>
<string name="AddExceptions">Add exceptions</string>
<string name="CustomHelp">Important: you won\'t be able to see Last Seen times for people with whom you don\'t share your Last Seen time. Approximate last seen will be shown instead (recently, within a week, witin a month).</string>
<string name="AlwaysShareWith">Always Share With</string>
<string name="NeverShareWith">Never Share With</string>
......@@ -334,9 +317,9 @@
<string name="NeverShareWithTitle">Never Share</string>
<string name="NeverShareWithPlaceholder">Never share with users...</string>
<string name="EmpryUsersPlaceholder">Add Users</string>
<string name="PrivacyAddUsers">Add %1$s to this list?</string>
<string name="PrivacyFloodControlError">Sorry, too many requests. Unable to change privacy settings now, please wait.</string>
<string name="ClearOtherSessionsHelp">Logs out all devices except for this one.</string>
<string name="RemoveFromListText">Tap and hold on user to delete.</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
......@@ -360,7 +343,6 @@
<string name="FromCamera">From camera</string>
<string name="FromGalley">From gallery</string>
<string name="DeletePhoto">Delete photo</string>
<string name="OpenPhoto">Open photo</string>
<string name="Set">Set</string>
<string name="OK">OK</string>
<!--messages-->
......@@ -403,10 +385,8 @@
<string name="NoHandleAppInstalled">You don\'t have applications that can handle the file type \'%1$s\', please install one to continue</string>
<string name="InviteUser">This user does not have Telegram yet, send an invitation?</string>
<string name="AreYouSure">Are you sure?</string>
<string name="AddContactQ">Add contact?</string>
<string name="AddToTheGroup">Add %1$s to the group?\n\nNumber of last messages to forward:</string>
<string name="ForwardMessagesTo">Forward messages to %1$s?</string>
<string name="DeleteChatQuestion">Delete this chat?</string>
<string name="SendMessagesTo">Send messages to %1$s?</string>
<string name="AreYouSureLogout">Are you sure you want to log out?</string>
<string name="AreYouSureSessions">Are you sure you want to terminate all other sessions?</string>
......@@ -418,7 +398,7 @@
<string name="AreYouSureDeleteContact">Are you sure you want to delete this contact?</string>
<string name="AreYouSureSecretChat">Are you sure you want to start a secret chat?</string>
<string name="AreYouSureRegistration">Are you sure you want to cancel registration?</string>
<string name="ForwardFromMyName">forward from my name</string>
<string name="AreYouSureClearHistory">Are you sure you want to clear history?</string>
<string name="SendMessagesToGroup">Send messages to %1$s?</string>
<string name="ForwardMessagesToGroup">Forward messages to %1$s?</string>
<string name="FeatureUnavailable">Sorry, this feature is currently not available in your country.</string>
......@@ -505,6 +485,18 @@
<string name="Weeks_few">%1$d weeks</string>
<string name="Weeks_many">%1$d weeks</string>
<string name="Weeks_other">%1$d weeks</string>
<string name="Months_zero">%1$d months</string>
<string name="Months_one">%1$d month</string>
<string name="Months_two">%1$d months</string>
<string name="Months_few">%1$d months</string>
<string name="Months_many">%1$d months</string>
<string name="Months_other">%1$d months</string>
<string name="Years_zero">%1$d years</string>
<string name="Years_one">%1$d year</string>
<string name="Years_two">%1$d years</string>
<string name="Years_few">%1$d years</string>
<string name="Years_many">%1$d years</string>
<string name="Years_other">%1$d years</string>
<string name="Users_zero">%1$d users</string>
<string name="Users_one">%1$d user</string>
<string name="Users_two">%1$d users</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment