More Android L design

This commit is contained in:
DrKLO 2014-11-17 05:44:57 +03:00
parent 934408c73f
commit f76fa00e12
191 changed files with 3195 additions and 2143 deletions

View File

@ -17,7 +17,7 @@ tasks.withType(JavaCompile) {
} }
dependencies { 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 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.2' compile 'net.hockeyapp.android:HockeySDK:3.0.2'
compile 'com.googlecode.mp4parser:isoparser:1.0.+' compile 'com.googlecode.mp4parser:isoparser:1.0.+'

View File

@ -17,8 +17,10 @@ import android.content.res.Configuration;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.util.StateSet;
import android.view.Display; import android.view.Display;
import android.view.Surface; import android.view.Surface;
import android.view.View; 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();
}
}
}
} }

View File

@ -54,6 +54,11 @@ public class ContactsController {
private String inviteText; private String inviteText;
private boolean updatingInviteText = false; 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 static class Contact {
public int id; public int id;
public ArrayList<String> phones = new ArrayList<String>(); public ArrayList<String> phones = new ArrayList<String>();
@ -119,6 +124,10 @@ public class ContactsController {
contactsLoaded = false; contactsLoaded = false;
contactsBookLoaded = false; contactsBookLoaded = false;
lastContactsVersions = ""; lastContactsVersions = "";
loadingDeleteInfo = 0;
deleteAccountTTL = 0;
loadingLastSeenInfo = 0;
privacyRules = null;
} }
public void checkInviteText() { public void checkInviteText() {
@ -1568,6 +1577,81 @@ public class ContactsController {
}, true, RPCRequest.RPCRequestClassGeneric); }, 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) { public static String formatName(String firstName, String lastName) {
String result = null; String result = null;
if (LocaleController.nameDisplayOrder == 1) { if (LocaleController.nameDisplayOrder == 1) {

View File

@ -427,4 +427,8 @@ public class ImageReceiver {
bitmapRect = null; bitmapRect = null;
} }
} }
public int getRoundRadius() {
return roundRadius;
}
} }

View File

@ -783,7 +783,7 @@ public class LocaleController {
public static String formatUserStatus(TLRPC.User user) { 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) { 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 { } else {
int currentTime = ConnectionsManager.getInstance().getCurrentTime(); int currentTime = ConnectionsManager.getInstance().getCurrentTime();
if (user.status.expires > currentTime) { if (user.status.expires > currentTime) {
@ -791,7 +791,13 @@ public class LocaleController {
} else { } else {
if (user.status.expires == -1) { if (user.status.expires == -1) {
return getString("Invisible", R.string.Invisible); return getString("Invisible", R.string.Invisible);
} else { } 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); return formatDateOnline(user.status.expires);
} }
} }

View File

@ -60,7 +60,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public boolean loadingBlockedUsers = false; public boolean loadingBlockedUsers = false;
public ArrayList<Integer> blockedUsers = new ArrayList<Integer>(); 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 HashMap<Integer, TLRPC.EncryptedChat> acceptingChats = new HashMap<Integer, TLRPC.EncryptedChat>();
private ArrayList<TLRPC.Updates> updatesQueue = new ArrayList<TLRPC.Updates>(); private ArrayList<TLRPC.Updates> updatesQueue = new ArrayList<TLRPC.Updates>();
private ArrayList<Long> pendingEncMessagesToDelete = new ArrayList<Long>(); private ArrayList<Long> pendingEncMessagesToDelete = new ArrayList<Long>();
@ -317,7 +316,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
printingStrings.clear(); printingStrings.clear();
totalDialogsCount = 0; totalDialogsCount = 0;
lastPrintingStringCount = 0; lastPrintingStringCount = 0;
hidenAddToContacts.clear();
updatesQueue.clear(); updatesQueue.clear();
pendingEncMessagesToDelete.clear(); pendingEncMessagesToDelete.clear();
delayedEncryptedChatUpdates.clear(); delayedEncryptedChatUpdates.clear();
@ -391,7 +389,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (user == null) { if (user == null) {
return false; return false;
} }
fromCache = fromCache && user.id / 1000 != 333; fromCache = fromCache && user.id / 1000 != 333 && user.id != 777000;
TLRPC.User oldUser = users.get(user.id); TLRPC.User oldUser = users.get(user.id);
if (!fromCache) { if (!fromCache) {
users.put(user.id, user); users.put(user.id, user);
@ -758,6 +756,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (user != null) { if (user != null) {
user.photo = UserConfig.getCurrentUser().photo; user.photo = UserConfig.getCurrentUser().photo;
} }
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL); NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
@ -1379,7 +1378,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (!isCache) { if (!isCache) {
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id); 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() { AndroidUtilities.runOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -3242,6 +3241,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
arr.add(obj); arr.add(obj);
pushMessages.add(obj); pushMessages.add(obj);
} else if (update instanceof TLRPC.TL_updatePrivacy) {
updatesOnMainThread.add(update);
} }
} }
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
@ -3299,7 +3300,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.User toDbUser = new TLRPC.User(); TLRPC.User toDbUser = new TLRPC.User();
toDbUser.id = update.user_id; toDbUser.id = update.user_id;
TLRPC.User currentUser = getUser(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) { if (currentUser != null) {
currentUser.id = update.user_id; currentUser.id = update.user_id;
currentUser.status = update.status; currentUser.status = update.status;

View File

@ -41,6 +41,8 @@ public class NotificationCenter {
public static final int hideEmojiKeyboard = 30; public static final int hideEmojiKeyboard = 30;
public static final int stopEncodingService = 31; public static final int stopEncodingService = 31;
public static final int didCreatedNewDeleteTask = 32; 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 wallpapersDidLoaded = 171;
public static final int closeOtherAppActivities = 702; public static final int closeOtherAppActivities = 702;

View File

@ -17,7 +17,6 @@ import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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 FrameLayout titleFrameLayout;
private ImageView backButtonImageView; private ImageView backButtonImageView;
private TextView titleTextView; private TextView titleTextView;
@ -47,6 +44,7 @@ public class ActionBar extends FrameLayout {
private ActionBarMenu menu; private ActionBarMenu menu;
private ActionBarMenu actionMode; private ActionBarMenu actionMode;
private View actionOverlay; private View actionOverlay;
private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21;
protected boolean isSearchFieldVisible; protected boolean isSearchFieldVisible;
protected int itemsBackgroundResourceId; protected int itemsBackgroundResourceId;
@ -64,9 +62,6 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.FILL_PARENT; layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
if (withStatusBar) {
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
titleFrameLayout.setLayoutParams(layoutParams); titleFrameLayout.setLayoutParams(layoutParams);
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0); titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
titleFrameLayout.setEnabled(false); titleFrameLayout.setEnabled(false);
@ -162,8 +157,9 @@ public class ActionBar extends FrameLayout {
subTitleTextView.setLayoutParams(layoutParams); subTitleTextView.setLayoutParams(layoutParams);
} }
ViewGroup.LayoutParams layoutParams1 = titleFrameLayout.getLayoutParams(); MarginLayoutParams layoutParams1 = (MarginLayoutParams) titleFrameLayout.getLayoutParams();
layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6)); layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6));
layoutParams1.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
titleFrameLayout.setLayoutParams(layoutParams1); titleFrameLayout.setLayoutParams(layoutParams1);
} }
@ -175,9 +171,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT; layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT;
layoutParams.height = height; layoutParams.height = height;
layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(54) : 0; layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(54) : 0;
if (withStatusBar) { layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
menu.setLayoutParams(layoutParams); menu.setLayoutParams(layoutParams);
menu.measure(width, height); menu.measure(width, height);
} }
@ -330,9 +324,7 @@ public class ActionBar extends FrameLayout {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)view.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)view.getLayoutParams();
layoutParams.width = LayoutParams.FILL_PARENT; layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.height = LayoutParams.FILL_PARENT; layoutParams.height = LayoutParams.FILL_PARENT;
if (withStatusBar) { layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
view.setLayoutParams(layoutParams); view.setLayoutParams(layoutParams);
} }
@ -343,13 +335,11 @@ public class ActionBar extends FrameLayout {
actionMode = new ActionBarMenu(getContext(), this); actionMode = new ActionBarMenu(getContext(), this);
actionMode.setBackgroundResource(R.drawable.editheader); actionMode.setBackgroundResource(R.drawable.editheader);
addView(actionMode); addView(actionMode);
actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams();
layoutParams.height = LayoutParams.FILL_PARENT; layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.width = LayoutParams.FILL_PARENT; layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.RIGHT; layoutParams.gravity = Gravity.RIGHT;
if (withStatusBar) {
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
actionMode.setLayoutParams(layoutParams); actionMode.setLayoutParams(layoutParams);
actionMode.setVisibility(GONE); actionMode.setVisibility(GONE);
return actionMode; return actionMode;
@ -414,9 +404,7 @@ public class ActionBar extends FrameLayout {
positionMenu(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight); positionMenu(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
positionTitle(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight); positionTitle(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
positionBackOverlay(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight); positionBackOverlay(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight);
if (Build.VERSION.SDK_INT >= 21) { actionBarHeight += occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
actionBarHeight += AndroidUtilities.statusBarHeight;
}
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(actionBarHeight + extraHeight, MeasureSpec.EXACTLY)); super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(actionBarHeight + extraHeight, MeasureSpec.EXACTLY));
} }
@ -495,14 +483,20 @@ public class ActionBar extends FrameLayout {
layoutParams.height = LayoutParams.MATCH_PARENT; layoutParams.height = LayoutParams.MATCH_PARENT;
actionOverlay.setLayoutParams(layoutParams); actionOverlay.setLayoutParams(layoutParams);
actionOverlay.measure(widthMeasureSpec, heightMeasureSpec); actionOverlay.measure(widthMeasureSpec, heightMeasureSpec);
if (withStatusBar) { layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0;
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
}
layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + AndroidUtilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0)); layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + AndroidUtilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0));
actionOverlay.setLayoutParams(layoutParams); actionOverlay.setLayoutParams(layoutParams);
} }
} }
public void setOccupyStatusBar(boolean value) {
occupyStatusBar = value;
}
public boolean getOccupyStatusBar() {
return occupyStatusBar;
}
public void setItemsBackground(int resourceId) { public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId; itemsBackgroundResourceId = resourceId;
if (backButtonImageView != null) { if (backButtonImageView != null) {

View File

@ -56,14 +56,46 @@ public class ActionBarLayout extends FrameLayout {
setOrientation(VERTICAL); setOrientation(VERTICAL);
} }
/*@Override @Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) { protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
int saveCount = canvas.save(); if (child instanceof ActionBar) {
canvas.clipRect(0, 0, getWidth(), getHeight()); return super.drawChild(canvas, child, drawingTime);
boolean result = super.drawChild(canvas, child, drawingTime); } else {
canvas.restoreToCount(saveCount); boolean wasActionBar = false;
return result; 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);
if (actionBarHeight != 0 && headerShadowDrawable != null) {
headerShadowDrawable.setBounds(0, actionBarHeight, getMeasuredWidth(), actionBarHeight + headerShadowDrawable.getIntrinsicHeight());
headerShadowDrawable.draw(canvas);
}
return result;
}
}
} }
private static Drawable headerShadowDrawable; private static Drawable headerShadowDrawable;
@ -79,21 +111,22 @@ public class ActionBarLayout extends FrameLayout {
public float innerTranslationX; public float innerTranslationX;
private boolean maybeStartTracking = false; private boolean maybeStartTracking;
protected boolean startedTracking = false; protected boolean startedTracking;
private int startedTrackingX; private int startedTrackingX;
private int startedTrackingY; private int startedTrackingY;
protected boolean animationInProgress = false; protected boolean animationInProgress;
private VelocityTracker velocityTracker = null; private VelocityTracker velocityTracker;
private boolean beginTrackingSent = false; private boolean beginTrackingSent;
private boolean transitionAnimationInProgress = false; private boolean transitionAnimationInProgress;
private long transitionAnimationStartTime; private long transitionAnimationStartTime;
private boolean inActionMode = false; private boolean inActionMode;
private int startedTrackingPointerId; private int startedTrackingPointerId;
private Runnable onCloseAnimationEndRunnable = null; private Runnable onCloseAnimationEndRunnable;
private Runnable onOpenAnimationEndRunnable = null; private Runnable onOpenAnimationEndRunnable;
private boolean useAlphaAnimations = false; private boolean useAlphaAnimations;
private View backgroundView; private View backgroundView;
private boolean removeActionBarExtraHeight;
private ActionBarLayoutDelegate delegate = null; private ActionBarLayoutDelegate delegate = null;
protected Activity parentActivity = null; protected Activity parentActivity = null;
@ -106,6 +139,7 @@ public class ActionBarLayout extends FrameLayout {
if (layerShadowDrawable == null) { if (layerShadowDrawable == null) {
layerShadowDrawable = getResources().getDrawable(R.drawable.layer_shadow); layerShadowDrawable = getResources().getDrawable(R.drawable.layer_shadow);
headerShadowDrawable = getResources().getDrawable(R.drawable.header_shadow);
scrimPaint = new Paint(); scrimPaint = new Paint();
} }
} }
@ -113,7 +147,6 @@ public class ActionBarLayout extends FrameLayout {
public void init(ArrayList<BaseFragment> stack) { public void init(ArrayList<BaseFragment> stack) {
fragmentsStack = stack; fragmentsStack = stack;
containerViewBack = new LinearLayoutContainer(parentActivity); containerViewBack = new LinearLayoutContainer(parentActivity);
//containerViewBack.setOrientation(LinearLayout.VERTICAL);
addView(containerViewBack); addView(containerViewBack);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT; layoutParams.width = LayoutParams.MATCH_PARENT;
@ -122,7 +155,6 @@ public class ActionBarLayout extends FrameLayout {
containerViewBack.setLayoutParams(layoutParams); containerViewBack.setLayoutParams(layoutParams);
containerView = new LinearLayoutContainer(parentActivity); containerView = new LinearLayoutContainer(parentActivity);
//containerView.setOrientation(LinearLayout.VERTICAL);
addView(containerView); addView(containerView);
layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT; layoutParams.width = LayoutParams.MATCH_PARENT;
@ -199,10 +231,10 @@ public class ActionBarLayout extends FrameLayout {
@Override @Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) { protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
int width = getWidth(); int width = getWidth() - getPaddingLeft() - getPaddingRight();
int translationX = (int) innerTranslationX; int translationX = (int) innerTranslationX + getPaddingRight();
int clipLeft = 0; int clipLeft = getPaddingLeft();
int clipRight = width; int clipRight = width + getPaddingLeft();
if (child == containerViewBack) { if (child == containerViewBack) {
clipRight = translationX; clipRight = translationX;
@ -296,6 +328,9 @@ public class ActionBarLayout extends FrameLayout {
if (parent != null) { if (parent != null) {
parent.removeView(lastFragment.actionBar); parent.removeView(lastFragment.actionBar);
} }
if (removeActionBarExtraHeight) {
lastFragment.actionBar.setOccupyStatusBar(false);
}
containerViewBack.addView(lastFragment.actionBar); containerViewBack.addView(lastFragment.actionBar);
} }
containerViewBack.addView(fragmentView); containerViewBack.addView(fragmentView);
@ -513,15 +548,15 @@ public class ActionBarLayout extends FrameLayout {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard); NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard);
} }
boolean needAnimation = Build.VERSION.SDK_INT > 10 && !forceWithoutAnimation && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); 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; final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;
fragment.setParentLayout(this); fragment.setParentLayout(this);
View fragmentView = fragment.createView(parentActivity.getLayoutInflater(), null); View fragmentView = fragment.createView(parentActivity.getLayoutInflater(), null);
if (fragment.needAddActionBar() && fragment.actionBar != null) { if (fragment.needAddActionBar() && fragment.actionBar != null) {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
}
containerViewBack.addView(fragment.actionBar); containerViewBack.addView(fragment.actionBar);
} }
containerViewBack.addView(fragmentView); containerViewBack.addView(fragmentView);
@ -553,8 +588,6 @@ public class ActionBarLayout extends FrameLayout {
if (needAnimation) { if (needAnimation) {
if (useAlphaAnimations && fragmentsStack.size() == 1) { if (useAlphaAnimations && fragmentsStack.size() == 1) {
presentFragmentInternalRemoveOld(removeLast, currentFragment); presentFragmentInternalRemoveOld(removeLast, currentFragment);
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
animatorSet.playTogether();
ArrayList<Object> animators = new ArrayList<Object>(); ArrayList<Object> animators = new ArrayList<Object>();
animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f)); animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f));
@ -639,9 +672,6 @@ public class ActionBarLayout extends FrameLayout {
AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus()); AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
} }
boolean needAnimation = Build.VERSION.SDK_INT > 10 && animated && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); 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); final BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
BaseFragment previousFragment = null; BaseFragment previousFragment = null;
if (fragmentsStack.size() > 1) { if (fragmentsStack.size() > 1) {
@ -657,6 +687,9 @@ public class ActionBarLayout extends FrameLayout {
previousFragment.setParentLayout(this); previousFragment.setParentLayout(this);
View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null); View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null);
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
containerView.addView(previousFragment.actionBar); containerView.addView(previousFragment.actionBar);
} }
containerView.addView(fragmentView); containerView.addView(fragmentView);
@ -700,7 +733,7 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.start(); currentAnimation.start();
} }
} else { } else {
if (needAnimation && useAlphaAnimations) { if (useAlphaAnimations) {
transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true; transitionAnimationInProgress = true;
@ -712,6 +745,9 @@ public class ActionBarLayout extends FrameLayout {
if (backgroundView != null) { if (backgroundView != null) {
backgroundView.setVisibility(GONE); backgroundView.setVisibility(GONE);
} }
if (drawerLayoutContainer != null) {
drawerLayoutContainer.setAllowOpenDrawer(true);
}
} }
}; };
@ -750,6 +786,9 @@ public class ActionBarLayout extends FrameLayout {
previousFragment.setParentLayout(this); previousFragment.setParentLayout(this);
View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null); View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null);
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
containerView.addView(previousFragment.actionBar); containerView.addView(previousFragment.actionBar);
} }
containerView.addView(fragmentView); containerView.addView(fragmentView);
@ -891,4 +930,8 @@ public class ActionBarLayout extends FrameLayout {
public DrawerLayoutContainer getDrawerLayoutContainer() { public DrawerLayoutContainer getDrawerLayoutContainer() {
return drawerLayoutContainer; return drawerLayoutContainer;
} }
public void setRemoveActionBarExtraHeight(boolean value) {
removeActionBarExtraHeight = value;
}
} }

View File

@ -9,6 +9,7 @@
package org.telegram.ui.ActionBar; package org.telegram.ui.ActionBar;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -58,19 +59,31 @@ public class ActionBarMenu extends LinearLayout {
return view; 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) { public ActionBarMenuItem addItem(int id, int icon) {
return addItem(id, icon, parentActionBar.itemsBackgroundResourceId); return addItem(id, icon, parentActionBar.itemsBackgroundResourceId);
} }
public ActionBarMenuItem addItem(int id, int icon, int backgroundResource) { 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 addItem(int id, int icon, int backgroundResource, int width) { 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, Drawable drawable, int width) {
ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource); ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource);
menuItem.setTag(id); menuItem.setTag(id);
menuItem.setScaleType(ImageView.ScaleType.CENTER); menuItem.setScaleType(ImageView.ScaleType.CENTER);
menuItem.setImageResource(icon); if (drawable != null) {
menuItem.setImageDrawable(drawable);
} else {
menuItem.setImageResource(icon);
}
addView(menuItem); addView(menuItem);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams();
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;

View File

@ -54,7 +54,7 @@ public class ActionBarMenuItem extends ImageView {
private View selectedMenuView; private View selectedMenuView;
private Runnable showMenuRunnable; private Runnable showMenuRunnable;
private boolean showFromBottom; private boolean showFromBottom;
private int height; private int menuHeight = AndroidUtilities.dp(16);
public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) { public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) {
super(context); super(context);
@ -135,7 +135,7 @@ public class ActionBarMenuItem extends ImageView {
showFromBottom = value; showFromBottom = value;
} }
public void addSubItem(int id, String text, int icon) { public TextView addSubItem(int id, String text, int icon) {
if (popupLayout == null) { if (popupLayout == null) {
rect = new Rect(); rect = new Rect();
location = new int[2]; location = new int[2];
@ -166,7 +166,7 @@ public class ActionBarMenuItem extends ImageView {
}); });
} }
TextView textView = new TextView(getContext()); TextView textView = new TextView(getContext());
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setBackgroundResource(R.drawable.list_selector); textView.setBackgroundResource(R.drawable.list_selector);
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
textView.setGravity(Gravity.CENTER_VERTICAL); textView.setGravity(Gravity.CENTER_VERTICAL);
@ -203,6 +203,8 @@ public class ActionBarMenuItem extends ImageView {
} }
} }
}); });
menuHeight += layoutParams.height;
return textView;
} }
public boolean hasSubMenu() { public boolean hasSubMenu() {
@ -245,25 +247,31 @@ public class ActionBarMenuItem extends ImageView {
popupWindow.setFocusable(true); popupWindow.setFocusable(true);
if (popupLayout.getMeasuredWidth() == 0) { if (popupLayout.getMeasuredWidth() == 0) {
if (showFromBottom) { if (showFromBottom) {
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -popupLayout.getMeasuredHeight() + AndroidUtilities.dp(12)); popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY());
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -popupLayout.getMeasuredHeight() + AndroidUtilities.dp(12), -1, -1); popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY(), -1, -1);
height = popupLayout.getMeasuredHeight();
} else { } else {
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); 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); popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
} }
} else { } else {
if (showFromBottom) { if (showFromBottom) {
if (height == 0) { popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY());
height = popupLayout.getMeasuredHeight();
}
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -height + AndroidUtilities.dp(12));
} else { } else {
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); 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() { public boolean toggleSearch() {
if (searchField == null) { if (searchField == null) {
return false; return false;
@ -407,7 +415,7 @@ public class ActionBarMenuItem extends ImageView {
super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom);
if (popupWindow != null && popupWindow.isShowing()) { if (popupWindow != null && popupWindow.isShowing()) {
if (showFromBottom) { 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 { } else {
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
} }

View File

@ -320,7 +320,7 @@ public class DrawerLayoutContainer extends FrameLayout {
} }
} }
} }
if (startedTracking) { if (startedTracking || drawerPosition != 0 && drawerPosition != drawerLayout.getMeasuredWidth()) {
float velX = velocityTracker.getXVelocity(); float velX = velocityTracker.getXVelocity();
float velY = velocityTracker.getYVelocity(); 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; boolean backAnimation = drawerPosition < drawerLayout.getMeasuredWidth() / 2.0f && (velX < 1500 || Math.abs(velX) < Math.abs(velY)) || velX < 0 && Math.abs(velX) >= 1500;
@ -458,9 +458,11 @@ public class DrawerLayoutContainer extends FrameLayout {
canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint); canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint);
} else if (shadowLeft != null) { } else if (shadowLeft != null) {
final float alpha = Math.max(0, Math.min((float) drawerPosition / AndroidUtilities.dp(20), 1.0f)); final float alpha = Math.max(0, Math.min((float) drawerPosition / AndroidUtilities.dp(20), 1.0f));
shadowLeft.setBounds(drawerPosition, child.getTop(), drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom()); if (alpha != 0) {
shadowLeft.setAlpha((int) (0xff * alpha)); shadowLeft.setBounds(drawerPosition, child.getTop(), drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom());
shadowLeft.draw(canvas); shadowLeft.setAlpha((int) (0xff * alpha));
shadowLeft.draw(canvas);
}
} }
return result; return result;
} }

View File

@ -247,6 +247,7 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
((UserCell) view).setChecked(checkedMap.containsKey(user.id)); ((UserCell) view).setChecked(checkedMap.containsKey(user.id));
} }
} else { } else {
((ProfileSearchCell) view).setData(user, null, null, name, username);
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1); ((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
if (ignoreUsers != null) { if (ignoreUsers != null) {
if (ignoreUsers.containsKey(user.id)) { if (ignoreUsers.containsKey(user.id)) {

View File

@ -18,12 +18,33 @@ import org.telegram.ui.Animation.AnimatorListenerAdapter10;
import org.telegram.ui.Animation.AnimatorSet10; import org.telegram.ui.Animation.AnimatorSet10;
import org.telegram.ui.Animation.View10; import org.telegram.ui.Animation.View10;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
public class AnimatorSetProxy { public class AnimatorSetProxy {
private Object animatorSet; 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() { public AnimatorSetProxy() {
if (View10.NEED_PROXY) { if (View10.NEED_PROXY) {
animatorSet = new AnimatorSet10(); animatorSet = new AnimatorSet10();
@ -32,12 +53,13 @@ public class AnimatorSetProxy {
} }
} }
@SuppressWarnings("unchecked")
public void playTogether(Object... items) { public void playTogether(Object... items) {
if (View10.NEED_PROXY) { 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); ((AnimatorSet10) animatorSet).playTogether(animators);
} else { } else {
Animator[] animators = Arrays.copyOf(items, items.length, Animator[].class); Animator[] animators = copyOf(items, items.length, Animator[].class);
((AnimatorSet) animatorSet).playTogether(animators); ((AnimatorSet) animatorSet).playTogether(animators);
} }
} }
@ -98,4 +120,9 @@ public class AnimatorSetProxy {
((AnimatorSet) animatorSet).setInterpolator(interpolator); ((AnimatorSet) animatorSet).setInterpolator(interpolator);
} }
} }
@Override
public boolean equals(Object o) {
return animatorSet == o;
}
} }

View File

@ -8,9 +8,11 @@
package org.telegram.ui.AnimationCompat; package org.telegram.ui.AnimationCompat;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
import org.telegram.ui.Animation.AnimatorListenerAdapter10;
import org.telegram.ui.Animation.ObjectAnimator10; import org.telegram.ui.Animation.ObjectAnimator10;
import org.telegram.ui.Animation.View10; import org.telegram.ui.Animation.View10;
@ -110,4 +112,13 @@ public class ObjectAnimatorProxy {
((ObjectAnimator) objectAnimator).cancel(); ((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;
}
} }

View File

@ -38,6 +38,7 @@ import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate { public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
private ListView listView; private ListView listView;
private ListAdapter listViewAdapter; private ListAdapter listViewAdapter;
private FrameLayout progressView; private FrameLayout progressView;
@ -93,7 +94,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
emptyTextView = new TextView(getParentActivity()); emptyTextView = new TextView(getParentActivity());
emptyTextView.setTextColor(0xff808080); emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(24); emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setVisibility(View.INVISIBLE); emptyTextView.setVisibility(View.INVISIBLE);
emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked)); emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));

View File

@ -74,6 +74,7 @@ public class ChatActionCell extends BaseCell {
textPaint.linkColor = 0xffffffff; textPaint.linkColor = 0xffffffff;
} }
imageReceiver = new ImageReceiver(this); imageReceiver = new ImageReceiver(this);
imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable = new AvatarDrawable(); avatarDrawable = new AvatarDrawable();
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
} }

View File

@ -65,6 +65,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
TAG = MediaController.getInstance().generateObserverTag(); TAG = MediaController.getInstance().generateObserverTag();
avatarImage = new ImageReceiver(this); avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(25));
seekBar = new SeekBar(context); seekBar = new SeekBar(context);
seekBar.delegate = this; seekBar.delegate = this;
progressView = new ProgressView(); progressView = new ProgressView();

View File

@ -156,6 +156,7 @@ public class ChatBaseCell extends BaseCell {
forwardNamePaint.setTextSize(AndroidUtilities.dp(14)); forwardNamePaint.setTextSize(AndroidUtilities.dp(14));
} }
avatarImage = new ImageReceiver(this); avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
avatarDrawable = new AvatarDrawable(); avatarDrawable = new AvatarDrawable();
} }

View File

@ -66,12 +66,13 @@ public class ChatContactCell extends ChatBaseCell {
phonePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); phonePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
phonePaint.setTextSize(AndroidUtilities.dp(15)); phonePaint.setTextSize(AndroidUtilities.dp(15));
phonePaint.setColor(0xff000000); phonePaint.setColor(0xff212121);
addContactDrawableIn = getResources().getDrawable(R.drawable.addcontact_blue); addContactDrawableIn = getResources().getDrawable(R.drawable.addcontact_blue);
addContactDrawableOut = getResources().getDrawable(R.drawable.addcontact_green); addContactDrawableOut = getResources().getDrawable(R.drawable.addcontact_green);
} }
avatarImage = new ImageReceiver(this); avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
avatarDrawable = new AvatarDrawable(); avatarDrawable = new AvatarDrawable();
} }

View File

@ -133,7 +133,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
infoPaint.setTextSize(AndroidUtilities.dp(12)); infoPaint.setTextSize(AndroidUtilities.dp(12));
namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
namePaint.setColor(0xff000000); namePaint.setColor(0xff212121);
namePaint.setTextSize(AndroidUtilities.dp(16)); namePaint.setTextSize(AndroidUtilities.dp(16));
docBackPaint = new Paint(); docBackPaint = new Paint();
@ -827,7 +827,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
menuDrawable = docMenuInDrawable; 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); menuDrawable.draw(canvas);
if (!imageDrawn) { if (!imageDrawn) {

View File

@ -566,29 +566,35 @@ public class DialogCell extends BaseCell {
continueUpdate = true; continueUpdate = true;
} }
} }
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) { if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
if (chat == null) { if (chat == null) {
continueUpdate = true; continueUpdate = true;
} }
} }
if ((mask & MessagesController.UPDATE_MASK_NAME) != 0) { if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
if (chat == null) { if (chat == null) {
continueUpdate = true; continueUpdate = true;
} }
} }
if ((mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) { if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
if (user == null) { if (user == null) {
continueUpdate = true; continueUpdate = true;
} }
} }
if ((mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) { if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
if (user == null) { if (user == null) {
continueUpdate = true; 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()) { if (message != null && lastUnreadState != message.isUnread()) {
continueUpdate = true; 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;
}
} }
} }

View File

@ -0,0 +1,48 @@
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Cells;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R;
public class 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));
}
}

View File

@ -31,7 +31,7 @@ public class TextCell extends FrameLayout {
super(context); super(context);
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1); textView.setLines(1);
textView.setMaxLines(1); textView.setMaxLines(1);

View File

@ -18,9 +18,10 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Views.Switch; import org.telegram.ui.Views.Switch;
public class TextCheckCell extends FrameLayout { public class TextCheckCell extends FrameLayoutFixed {
private TextView textView; private TextView textView;
private Switch checkBox; private Switch checkBox;
@ -37,7 +38,7 @@ public class TextCheckCell extends FrameLayout {
} }
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1); textView.setLines(1);
textView.setMaxLines(1); textView.setMaxLines(1);

View File

@ -40,7 +40,7 @@ public class TextColorCell extends FrameLayout {
} }
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1); textView.setLines(1);
textView.setMaxLines(1); textView.setMaxLines(1);

View File

@ -29,7 +29,7 @@ public class TextDetailCell extends FrameLayout {
super(context); super(context);
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1); textView.setLines(1);
textView.setMaxLines(1); textView.setMaxLines(1);

View File

@ -0,0 +1,120 @@
/*
* 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);
}
}
}

View File

@ -13,13 +13,13 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; 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 textView;
private TextView valueTextView; private TextView valueTextView;
@ -37,7 +37,7 @@ public class TextDetailSettingsCell extends FrameLayout {
} }
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1); textView.setLines(1);
textView.setMaxLines(1); textView.setMaxLines(1);

View File

@ -0,0 +1,50 @@
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Cells;
import android.content.Context;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
public class TextInfoPrivacyCell extends FrameLayout {
private TextView textView;
public TextInfoPrivacyCell(Context context) {
super(context);
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.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(17);
layoutParams.rightMargin = AndroidUtilities.dp(17);
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
textView.setLayoutParams(layoutParams);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
public void setText(String text) {
textView.setText(text);
}
}

View File

@ -15,6 +15,7 @@ import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
@ -24,6 +25,7 @@ public class TextSettingsCell extends FrameLayout {
private TextView textView; private TextView textView;
private TextView valueTextView; private TextView valueTextView;
private ImageView valueImageView;
private static Paint paint; private static Paint paint;
private boolean needDivider; private boolean needDivider;
@ -37,7 +39,7 @@ public class TextSettingsCell extends FrameLayout {
} }
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xff000000); textView.setTextColor(0xff212121);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1); textView.setLines(1);
textView.setMaxLines(1); textView.setMaxLines(1);
@ -69,6 +71,18 @@ public class TextSettingsCell extends FrameLayout {
layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17);
layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT; layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT;
valueTextView.setLayoutParams(layoutParams); 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 @Override
@ -77,6 +91,9 @@ public class TextSettingsCell extends FrameLayout {
int availableWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - AndroidUtilities.dp(34); int availableWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - AndroidUtilities.dp(34);
int width = availableWidth / 2; 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) { if (valueTextView.getVisibility() == VISIBLE) {
valueTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)); valueTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
width = availableWidth - valueTextView.getMeasuredWidth() - AndroidUtilities.dp(8); 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) { public void setTextAndValue(String text, String value, boolean divider) {
textView.setText(text); textView.setText(text);
valueTextView.setText(value); valueImageView.setVisibility(GONE);
valueTextView.setVisibility(VISIBLE); 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; needDivider = divider;
setWillNotDraw(!divider); setWillNotDraw(!divider);
} }

View File

@ -16,6 +16,7 @@ import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -74,25 +75,31 @@ public class ChangeChatNameActivity extends BaseFragment {
}); });
ActionBarMenu menu = actionBar.createMenu(); 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); TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
fragmentView = new LinearLayout(inflater.getContext()); fragmentView = new LinearLayout(inflater.getContext());
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); 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); ((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 = new EditText(inflater.getContext());
firstNameField.setText(currentChat.title); firstNameField.setText(currentChat.title);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19); firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xffa3a3a3); firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff000000); firstNameField.setTextColor(0xff212121);
firstNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
firstNameField.setMaxLines(3); firstNameField.setMaxLines(3);
firstNameField.setPadding(0, 0, 0, 0);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); 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_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE); firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
AndroidUtilities.clearCursorDrawable(firstNameField); AndroidUtilities.clearCursorDrawable(firstNameField);
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
@ -104,17 +111,14 @@ public class ChangeChatNameActivity extends BaseFragment {
return false; return false;
} }
}); });
if (LocaleController.isRTL) {
firstNameField.setGravity(Gravity.RIGHT);
}
((LinearLayout) fragmentView).addView(firstNameField); ((LinearLayout) fragmentView).addView(firstNameField);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(15); layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.height = AndroidUtilities.dp(36);
layoutParams.rightMargin = AndroidUtilities.dp(16); layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
firstNameField.setLayoutParams(layoutParams); firstNameField.setLayoutParams(layoutParams);
if (chat_id > 0) { if (chat_id > 0) {

View File

@ -15,6 +15,7 @@ import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; 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.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Views.SettingsSectionLayout;
public class ChangeNameActivity extends BaseFragment { public class ChangeNameActivity extends BaseFragment {
@ -67,9 +67,7 @@ public class ChangeNameActivity extends BaseFragment {
}); });
ActionBarMenu menu = actionBar.createMenu(); 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(UserConfig.getClientUserId()); TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
@ -78,25 +76,34 @@ public class ChangeNameActivity extends BaseFragment {
fragmentView = new LinearLayout(inflater.getContext()); fragmentView = new LinearLayout(inflater.getContext());
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); 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); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
SettingsSectionLayout settingsSectionLayout = new SettingsSectionLayout(inflater.getContext()); @Override
((LinearLayout) fragmentView).addView(settingsSectionLayout); public boolean onTouch(View v, MotionEvent event) {
settingsSectionLayout.setText(LocaleController.getString("YourFirstNameAndLastName", R.string.YourFirstNameAndLastName).toUpperCase()); return true;
}
});
firstNameField = new EditText(inflater.getContext()); firstNameField = new EditText(inflater.getContext());
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19); firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xffa3a3a3); firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff000000); firstNameField.setTextColor(0xff212121);
firstNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
firstNameField.setMaxLines(1); firstNameField.setMaxLines(1);
firstNameField.setLines(1); firstNameField.setLines(1);
firstNameField.setSingleLine(true); firstNameField.setSingleLine(true);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); 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.setImeOptions(EditorInfo.IME_ACTION_NEXT);
firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName)); 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() { firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
@ -108,26 +115,27 @@ public class ChangeNameActivity extends BaseFragment {
return false; 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 = new EditText(inflater.getContext());
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19); lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
lastNameField.setHintTextColor(0xffa3a3a3); lastNameField.setHintTextColor(0xff979797);
lastNameField.setTextColor(0xff000000); lastNameField.setTextColor(0xff212121);
lastNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
lastNameField.setMaxLines(1); lastNameField.setMaxLines(1);
lastNameField.setLines(1); lastNameField.setLines(1);
lastNameField.setSingleLine(true); lastNameField.setSingleLine(true);
lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); 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.setImeOptions(EditorInfo.IME_ACTION_DONE);
lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName)); 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() { lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
@ -138,13 +146,6 @@ public class ChangeNameActivity extends BaseFragment {
return false; 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) { if (user != null) {
firstNameField.setText(user.first_name); firstNameField.setText(user.first_name);
@ -190,6 +191,7 @@ public class ChangeNameActivity extends BaseFragment {
user.last_name = req.last_name; user.last_name = req.last_name;
} }
UserConfig.saveConfig(true); UserConfig.saveConfig(true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME); NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override

View File

@ -21,6 +21,7 @@ import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; 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.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Views.SettingsSectionLayout;
import java.util.ArrayList; import java.util.ArrayList;
@ -77,7 +77,7 @@ public class ChangeUsernameActivity extends BaseFragment {
}); });
ActionBarMenu menu = actionBar.createMenu(); 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()); TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
@ -86,20 +86,21 @@ public class ChangeUsernameActivity extends BaseFragment {
fragmentView = new LinearLayout(inflater.getContext()); fragmentView = new LinearLayout(inflater.getContext());
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); 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); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
SettingsSectionLayout settingsSectionLayout = new SettingsSectionLayout(inflater.getContext()); @Override
((LinearLayout) fragmentView).addView(settingsSectionLayout); public boolean onTouch(View v, MotionEvent event) {
settingsSectionLayout.setText(LocaleController.getString("Username", R.string.Username).toUpperCase()); return true;
}
});
firstNameField = new EditText(inflater.getContext()); firstNameField = new EditText(inflater.getContext());
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19); firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xffa3a3a3); firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff000000); firstNameField.setTextColor(0xff212121);
firstNameField.setPadding(AndroidUtilities.dp(15), 0, AndroidUtilities.dp(15), AndroidUtilities.dp(15));
firstNameField.setMaxLines(1); firstNameField.setMaxLines(1);
firstNameField.setLines(1); firstNameField.setLines(1);
firstNameField.setPadding(0, 0, 0, 0);
firstNameField.setSingleLine(true); firstNameField.setSingleLine(true);
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); 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_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
@ -119,9 +120,11 @@ public class ChangeUsernameActivity extends BaseFragment {
((LinearLayout) fragmentView).addView(firstNameField); ((LinearLayout) fragmentView).addView(firstNameField);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams(); 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.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
firstNameField.setLayoutParams(layoutParams); firstNameField.setLayoutParams(layoutParams);
if (user != null && user.username != null && user.username.length() > 0) { 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 = new TextView(inflater.getContext());
checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); 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); checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
((LinearLayout) fragmentView).addView(checkTextView); ((LinearLayout) fragmentView).addView(checkTextView);
layoutParams = (LinearLayout.LayoutParams)checkTextView.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams)checkTextView.getLayoutParams();
@ -139,12 +141,13 @@ public class ChangeUsernameActivity extends BaseFragment {
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
checkTextView.setLayoutParams(layoutParams); checkTextView.setLayoutParams(layoutParams);
TextView helpTextView = new TextView(inflater.getContext()); TextView helpTextView = new TextView(inflater.getContext());
helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
helpTextView.setTextColor(0xff6d6d72); helpTextView.setTextColor(0xff6d6d72);
helpTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0);
helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
helpTextView.setText(Html.fromHtml(LocaleController.getString("UsernameHelp", R.string.UsernameHelp))); helpTextView.setText(Html.fromHtml(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
((LinearLayout) fragmentView).addView(helpTextView); ((LinearLayout) fragmentView).addView(helpTextView);
@ -153,6 +156,8 @@ public class ChangeUsernameActivity extends BaseFragment {
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
layoutParams.leftMargin = AndroidUtilities.dp(24);
layoutParams.rightMargin = AndroidUtilities.dp(24);
helpTextView.setLayoutParams(layoutParams); helpTextView.setLayoutParams(layoutParams);
firstNameField.addTextChangedListener(new TextWatcher() { firstNameField.addTextChangedListener(new TextWatcher() {

View File

@ -8,9 +8,6 @@
package org.telegram.ui; package org.telegram.ui;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -41,7 +38,6 @@ import android.webkit.MimeTypeMap;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -65,6 +61,10 @@ import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.Adapters.BaseFragmentAdapter; 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.ChatActionCell;
import org.telegram.ui.Cells.ChatAudioCell; import org.telegram.ui.Cells.ChatAudioCell;
import org.telegram.ui.Cells.ChatBaseCell; 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.ActionBar.BaseFragment;
import org.telegram.ui.Views.ChatActivityEnterView; import org.telegram.ui.Views.ChatActivityEnterView;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Views.LayoutListView; import org.telegram.ui.Views.LayoutListView;
import org.telegram.ui.Views.SizeNotifierRelativeLayout; 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 org.telegram.ui.Views.TypingDotsDrawable;
import java.io.File; import java.io.File;
@ -98,13 +99,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TLRPC.EncryptedChat currentEncryptedChat; private TLRPC.EncryptedChat currentEncryptedChat;
private boolean userBlocked = false; private boolean userBlocked = false;
private View topPanel;
private View progressView; private View progressView;
private View bottomOverlay; private View bottomOverlay;
private ChatAdapter chatAdapter; private ChatAdapter chatAdapter;
private ChatActivityEnterView chatActivityEnterView; private ChatActivityEnterView chatActivityEnterView;
private View timeItem; private ActionBarMenuItem timeItem;
private View menuItem; private TimerDrawable timerDrawable;
private ActionBarMenuItem menuItem;
private TextView addContactItem;
private LayoutListView chatListView; private LayoutListView chatListView;
private BackupImageView avatarImageView; private BackupImageView avatarImageView;
private TextView bottomOverlayChatText; private TextView bottomOverlayChatText;
@ -116,12 +118,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TextView onlineTextView; private TextView onlineTextView;
private FrameLayout avatarContainer; private FrameLayout avatarContainer;
private TextView bottomOverlayText; private TextView bottomOverlayText;
private TextView secretViewStatusTextView;
private TextView selectedMessagesCountTextView;
private MessageObject selectedObject; private MessageObject selectedObject;
private MessageObject forwaringMessage; private MessageObject forwaringMessage;
private TextView secretViewStatusTextView;
private TimerButton timerButton;
private TextView selectedMessagesCountTextView;
private boolean paused = true; private boolean paused = true;
private boolean readWhenResume = false; private boolean readWhenResume = false;
@ -130,9 +131,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean scrollToTopOnResume = false; private boolean scrollToTopOnResume = false;
private boolean scrollToTopUnReadOnResume = false; private boolean scrollToTopUnReadOnResume = false;
private boolean isCustomTheme = false; private boolean isCustomTheme = false;
private ImageView topPlaneClose;
private View pagedownButton; private View pagedownButton;
private TextView topPanelText;
private long dialog_id; private long dialog_id;
private boolean isBroadcast = false; private boolean isBroadcast = false;
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>(); 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_video = 8;
private final static int attach_document = 9; private final static int attach_document = 9;
private final static int attach_location = 10; 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() { AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() {
@Override @Override
@ -438,18 +440,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat != null) { if (currentEncryptedChat != null) {
MediaController.getInstance().stopMediaObserver(); MediaController.getInstance().stopMediaObserver();
} }
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
AndroidUtilities.unlockOrientation(getParentActivity()); AndroidUtilities.unlockOrientation(getParentActivity());
MediaController.getInstance().stopAudio(); MediaController.getInstance().stopAudio();
} }
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
lastPrintString = null;
lastStatus = null;
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout); actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override @Override
public void onItemClick(int id) { public void onItemClick(final int id) {
if (id == -1) { if (id == -1) {
finishFragment(); finishFragment();
} else if (id == -2) { } else if (id == -2) {
@ -606,17 +613,79 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MessagesActivity fragment = new MessagesActivity(args); MessagesActivity fragment = new MessagesActivity(args);
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(ChatActivity.this);
presentFragment(fragment); 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); actionBar.addView(avatarContainer);
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); 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.width = FrameLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.rightMargin = AndroidUtilities.dp(48 + (currentEncryptedChat != null ? 48 : 0)); layoutParams2.rightMargin = AndroidUtilities.dp(40);
layoutParams2.leftMargin = AndroidUtilities.dp(64); layoutParams2.leftMargin = AndroidUtilities.dp(56);
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
avatarContainer.setLayoutParams(layoutParams2); avatarContainer.setLayoutParams(layoutParams2);
avatarContainer.setOnClickListener(new View.OnClickListener() { avatarContainer.setOnClickListener(new View.OnClickListener() {
@ -657,6 +726,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.width = AndroidUtilities.dp(42); layoutParams2.width = AndroidUtilities.dp(42);
layoutParams2.height = AndroidUtilities.dp(42); layoutParams2.height = AndroidUtilities.dp(42);
layoutParams2.topMargin = AndroidUtilities.dp(3); layoutParams2.topMargin = AndroidUtilities.dp(3);
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
avatarImageView.setLayoutParams(layoutParams2); avatarImageView.setLayoutParams(layoutParams2);
nameTextView = new TextView(getParentActivity()); nameTextView = new TextView(getParentActivity());
@ -708,43 +778,42 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
if (currentEncryptedChat != null) { 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); menuItem = 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); menuItem.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); menuItem.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); menuItem.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); menuItem.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.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location);
menuItem = item; menuItem.setShowFromBottom(true);
item.setShowFromBottom(true); menuItem.setBackgroundDrawable(null);
item.setBackground(null);
actionModeViews.clear(); actionModeViews.clear();
final ActionBarMenu actionMode = actionBar.createActionMode(); final ActionBarMenu actionMode = actionBar.createActionMode();
actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode)); actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
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);
selectedMessagesCountTextView = new TextView(actionMode.getContext()); selectedMessagesCountTextView = new TextView(actionMode.getContext());
selectedMessagesCountTextView.setTextSize(18); selectedMessagesCountTextView.setTextSize(18);
selectedMessagesCountTextView.setTextColor(0xff000000); selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
selectedMessagesCountTextView.setTextColor(0xff737373);
selectedMessagesCountTextView.setSingleLine(true); selectedMessagesCountTextView.setSingleLine(true);
selectedMessagesCountTextView.setLines(1); selectedMessagesCountTextView.setLines(1);
selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); 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.setGravity(Gravity.CENTER_VERTICAL);
selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
@ -753,7 +822,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
}); });
actionMode.addView(selectedMessagesCountTextView); actionMode.addView(selectedMessagesCountTextView);
layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
layoutParams.weight = 1; layoutParams.weight = 1;
layoutParams.width = 0; layoutParams.width = 0;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; 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)); emptyView.setText(LocaleController.getString("NoMessages", R.string.NoMessages));
chatListView = (LayoutListView)fragmentView.findViewById(R.id.chat_list_view); chatListView = (LayoutListView)fragmentView.findViewById(R.id.chat_list_view);
chatListView.setAdapter(chatAdapter = new ChatAdapter(getParentActivity())); 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); bottomOverlay = fragmentView.findViewById(R.id.bottom_overlay);
bottomOverlayText = (TextView)fragmentView.findViewById(R.id.bottom_overlay_text); bottomOverlayText = (TextView)fragmentView.findViewById(R.id.bottom_overlay_text);
bottomOverlayChat = fragmentView.findViewById(R.id.bottom_overlay_chat); bottomOverlayChat = fragmentView.findViewById(R.id.bottom_overlay_chat);
@ -1148,37 +1214,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
if (show) { if (show) {
if (pagedownButton.getVisibility() == View.GONE) { if (pagedownButton.getVisibility() == View.GONE) {
if (Build.VERSION.SDK_INT > 13 && animated) { if (animated) {
pagedownButton.setVisibility(View.VISIBLE); pagedownButton.setVisibility(View.VISIBLE);
pagedownButton.setAlpha(0); ViewProxy.setAlpha(pagedownButton, 0);
pagedownButton.animate().alpha(1).setDuration(200).setListener(null).start(); ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "alpha", 1.0f).setDuration(200).start();
} else { } else {
pagedownButton.setVisibility(View.VISIBLE); pagedownButton.setVisibility(View.VISIBLE);
} }
} }
} else { } else {
if (pagedownButton.getVisibility() == View.VISIBLE) { if (pagedownButton.getVisibility() == View.VISIBLE) {
if (Build.VERSION.SDK_INT > 13 && animated) { if (animated) {
pagedownButton.animate().alpha(0).setDuration(200).setListener(new Animator.AnimatorListener() { ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "alpha", 0.0f).setDuration(200).addListener(new AnimatorListenerAdapterProxy() {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationEnd(Object animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
pagedownButton.setVisibility(View.GONE); pagedownButton.setVisibility(View.GONE);
} }
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}).start(); }).start();
} else { } else {
pagedownButton.setVisibility(View.GONE); pagedownButton.setVisibility(View.GONE);
@ -1241,17 +1292,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
if (timeItem != null) { if (timeItem != null) {
timerButton = (TimerButton)timeItem.findViewById(R.id.chat_timer); timerDrawable.setTime(currentEncryptedChat.ttl);
timerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
showAlertDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat));
}
});
timerButton.setTime(currentEncryptedChat.ttl);
} }
checkAndUpdateAvatar(); checkAndUpdateAvatar();
@ -1426,11 +1467,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
if (!selectedMessagesIds.isEmpty()) { if (!selectedMessagesIds.isEmpty()) {
selectedMessagesCountTextView.setText(LocaleController.formatString("Selected", R.string.Selected, selectedMessagesIds.size())); selectedMessagesCountTextView.setText(String.format("%d", selectedMessagesIds.size()));
} }
} }
private void updateTitle() { private void updateTitle() {
if (nameTextView == null) {
return;
}
if (currentChat != null) { if (currentChat != null) {
nameTextView.setText(currentChat.title); nameTextView.setText(currentChat.title);
} else if (currentUser != null) { } else if (currentUser != null) {
@ -1447,6 +1491,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
private void updateSubtitle() { private void updateSubtitle() {
if (onlineTextView == null) {
return;
}
CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id); CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id);
if (printString != null) { if (printString != null) {
printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""}); printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""});
@ -1493,15 +1540,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
if (start) { if (start) {
try { try {
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null); if (onlineTextView != null) {
onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null);
typingDotsDrawable.start(); onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
}
if (typingDotsDrawable != null) {
typingDotsDrawable.start();
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else { } else {
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); if (onlineTextView != null) {
onlineTextView.setCompoundDrawablePadding(0); onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
onlineTextView.setCompoundDrawablePadding(0);
}
if (typingDotsDrawable != null) { if (typingDotsDrawable != null) {
typingDotsDrawable.stop(); typingDotsDrawable.stop();
} }
@ -1989,9 +2042,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (MessageObject obj : arr) { for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && 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; 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()) { if (obj.isOut() && obj.isSending()) {
scrollToLastMessage(); scrollToLastMessage();
@ -2035,9 +2088,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int oldCount = messages.size(); int oldCount = messages.size();
for (MessageObject obj : arr) { for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && 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; 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)) { if (messagesDict.containsKey(obj.messageOwner.id)) {
continue; continue;
@ -2383,11 +2436,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
private void updateContactStatus() { private void updateContactStatus() {
if (topPanel == null) { if (addContactItem == null) {
return; return;
} }
if (currentUser == null) { if (currentUser == null) {
topPanel.setVisibility(View.GONE); addContactItem.setVisibility(View.GONE);
} else { } else {
TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id); TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id);
if (user != null) { 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 || currentUser instanceof TLRPC.TL_userEmpty || currentUser instanceof TLRPC.TL_userDeleted
|| ContactsController.getInstance().isLoadingContacts() || 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()))) { || (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 { } else {
topPanel.setVisibility(View.VISIBLE); addContactItem.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);
}
if (currentUser.phone != null && currentUser.phone.length() != 0) { if (currentUser.phone != null && currentUser.phone.length() != 0) {
if (MessagesController.getInstance().hidenAddToContacts.get(currentUser.id) != null) { addContactItem.setText(LocaleController.getString("AddToContacts", R.string.AddToContacts));
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 { } else {
if (MessagesController.getInstance().hidenAddToContacts.get(currentUser.id) != null) { addContactItem.setText(LocaleController.getString("ShareMyContactInfo", R.string.ShareMyContactInfo));
topPanel.setVisibility(View.INVISIBLE);
} 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);
}
});
}
} }
} }
} }
@ -2475,7 +2467,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
checkActionBarMenu(); checkActionBarMenu();
@ -2605,12 +2599,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return false; return false;
} }
if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
selectedMessagesCountTextView.setTextSize(16);
} else {
selectedMessagesCountTextView.setTextSize(18); 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(); 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); avatarContainer.setLayoutParams(layoutParams);
return false; return false;
} }
@ -2799,21 +2795,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
actionBar.showActionMode(); actionBar.showActionMode();
if (Build.VERSION.SDK_INT >= 11) {
AnimatorSet animatorSet = new AnimatorSet(); AnimatorSetProxy animatorSet = new AnimatorSetProxy();
ArrayList<Animator> animators = new ArrayList<Animator>(); ArrayList<Object> animators = new ArrayList<Object>();
for (int a = 0; a < actionModeViews.size(); a++) { for (int a = 0; a < actionModeViews.size(); a++) {
View view = actionModeViews.get(a); View view = actionModeViews.get(a);
if (a < 2) { AndroidUtilities.clearDrawableAnimation(view);
animators.add(ObjectAnimator.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0)); if (a < 1) {
} else { animators.add(ObjectAnimatorProxy.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0));
animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } else {
} animators.add(ObjectAnimatorProxy.ofFloat(view, "scaleY", 0.1f, 1.0f));
} }
animatorSet.playTogether(animators);
animatorSet.setDuration(250);
animatorSet.start();
} }
animatorSet.playTogether(animators);
animatorSet.setDuration(250);
animatorSet.start();
addToSelectedMessages(message); addToSelectedMessages(message);
updateActionModeTitle(); updateActionModeTitle();
updateVisibleRows(); updateVisibleRows();
@ -2951,9 +2948,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putInt("chat_id", -lower_part); args.putInt("chat_id", -lower_part);
} }
forwardSelectedMessages(did, param); forwardSelectedMessages(did, param);
presentFragment(new ChatActivity(args), true); ChatActivity chatActivity = new ChatActivity(args);
presentFragment(chatActivity, true);
if (!AndroidUtilities.isTablet()) { if (!AndroidUtilities.isTablet()) {
removeSelfFromStack(); removeSelfFromStack();
chatActivity.getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} }
} else { } else {
activity.finishFragment(); activity.finishFragment();
@ -3095,7 +3094,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
object.viewY = coords[1] - AndroidUtilities.statusBarHeight; object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = chatListView; object.parentView = chatListView;
object.imageReceiver = imageReceiver; object.imageReceiver = imageReceiver;
object.thumb = object.imageReceiver.getBitmap(); object.thumb = imageReceiver.getBitmap();
object.radius = imageReceiver.getRoundRadius();
return object; return object;
} }
} }

View File

@ -10,14 +10,21 @@ package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle; 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.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
@ -40,8 +47,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
private EditText firstNameField; private EditText firstNameField;
private EditText lastNameField; private EditText lastNameField;
private BackupImageView avatarImage; private BackupImageView avatarImage;
private TextView onlineText; private TextView nameTextView;
private TextView phoneText; private TextView onlineTextView;
private int user_id; private int user_id;
private boolean addContact; private boolean addContact;
@ -98,27 +105,148 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
}); });
ActionBarMenu menu = actionBar.createMenu(); 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) { <LinearLayout
if (phone != null) { android:gravity="center_vertical"
user.phone = PhoneFormat.stripExceptNumbers(phone); 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;
} }
} });
onlineText = (TextView)fragmentView.findViewById(R.id.settings_online); FrameLayout frameLayout = new FrameLayout(getParentActivity());
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image); 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);
avatarImage = new BackupImageView(getParentActivity());
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
avatarImage.processDetach = false; avatarImage.processDetach = false;
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32)); frameLayout.addView(avatarImage);
phoneText = (TextView)fragmentView.findViewById(R.id.settings_name); FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf"); layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
phoneText.setTypeface(typeface); 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)); 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() { firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
@ -130,8 +258,27 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
return false; 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)); 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() { lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { 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 != null) {
if (user.phone == null) {
if (phone != null) {
user.phone = PhoneFormat.stripExceptNumbers(phone);
}
}
firstNameField.setText(user.first_name); firstNameField.setText(user.first_name);
firstNameField.setSelection(firstNameField.length()); firstNameField.setSelection(firstNameField.length());
lastNameField.setText(user.last_name); lastNameField.setText(user.last_name);
@ -151,7 +304,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
updateAvatarLayout(); updateAvatarLayout();
} else { } else {
ViewGroup parent = (ViewGroup)fragmentView.getParent(); ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) { if (parent != null) {
parent.removeView(fragmentView); parent.removeView(fragmentView);
} }
@ -160,15 +313,15 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
} }
private void updateAvatarLayout() { private void updateAvatarLayout() {
if (phoneText == null) { if (nameTextView == null) {
return; return;
} }
TLRPC.User user = MessagesController.getInstance().getUser(user_id); TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null) { if (user == null) {
return; return;
} }
phoneText.setText(PhoneFormat.getInstance().format("+" + user.phone)); nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
onlineText.setText(LocaleController.formatUserStatus(user)); onlineTextView.setText(LocaleController.formatUserStatus(user));
TLRPC.FileLocation photo = null; TLRPC.FileLocation photo = null;
if (user.photo != null) { if (user.photo != null) {
@ -179,7 +332,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
public void didReceivedNotification(int id, Object... args) { public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) { 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) { if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
updateAvatarLayout(); updateAvatarLayout();
} }

View File

@ -25,6 +25,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -183,27 +184,44 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(getParentActivity());
emptyTextView = new TextView(getParentActivity()); LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextView.setTextColor(0xff808080); emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextView.setTextSize(24); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
emptyTextView.setGravity(Gravity.CENTER); ((FrameLayout) fragmentView).addView(emptyTextLayout);
emptyTextView.setVisibility(View.INVISIBLE); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
((FrameLayout) fragmentView).addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP; layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams); emptyTextLayout.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() { emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return true; 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 = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
@ -348,6 +366,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (absListView.isFastScrollEnabled()) {
AndroidUtilities.clearDrawableAnimation(absListView);
}
} }
}); });
} else { } else {

View File

@ -18,6 +18,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -127,27 +128,44 @@ public class CountrySelectActivity extends BaseFragment {
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(getParentActivity());
emptyTextView = new TextView(getParentActivity()); LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextView.setTextColor(0xff808080); emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextView.setTextSize(24); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
emptyTextView.setGravity(Gravity.CENTER); ((FrameLayout) fragmentView).addView(emptyTextLayout);
emptyTextView.setVisibility(View.INVISIBLE); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
((FrameLayout) fragmentView).addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP; layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams); emptyTextLayout.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() { emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return true; 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 = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
@ -198,6 +216,9 @@ public class CountrySelectActivity extends BaseFragment {
@Override @Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (absListView.isFastScrollEnabled()) {
AndroidUtilities.clearDrawableAnimation(absListView);
}
} }
}); });
} else { } else {

View File

@ -24,6 +24,7 @@ import android.widget.AdapterView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.R; 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.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; 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 org.telegram.ui.ActionBar.BaseFragment;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -261,6 +262,7 @@ public class DocumentSelectActivity extends BaseFragment {
} else { } else {
emptyView.setText(LocaleController.getString("NotMounted", R.string.NotMounted)); emptyView.setText(LocaleController.getString("NotMounted", R.string.NotMounted));
} }
AndroidUtilities.clearDrawableAnimation(listView);
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
return true; return true;
} }
@ -309,6 +311,7 @@ public class DocumentSelectActivity extends BaseFragment {
item.file = file; item.file = file;
if (file.isDirectory()) { if (file.isDirectory()) {
item.icon = R.drawable.ic_directory; item.icon = R.drawable.ic_directory;
item.subtitle = LocaleController.getString("Folder", R.string.Folder);
} else { } else {
String fname = file.getName(); String fname = file.getName();
String[] sp = fname.split("\\."); String[] sp = fname.split("\\.");
@ -323,10 +326,11 @@ public class DocumentSelectActivity extends BaseFragment {
} }
ListItem item = new ListItem(); ListItem item = new ListItem();
item.title = ".."; item.title = "..";
item.subtitle = ""; item.subtitle = LocaleController.getString("Folder", R.string.Folder);
item.icon = R.drawable.ic_directory; item.icon = R.drawable.ic_directory;
item.file = null; item.file = null;
items.add(0, item); items.add(0, item);
AndroidUtilities.clearDrawableAnimation(listView);
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
return true; return true;
} }
@ -335,11 +339,7 @@ public class DocumentSelectActivity extends BaseFragment {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
} }
new AlertDialog.Builder(getParentActivity()) new AlertDialog.Builder(getParentActivity()).setTitle(LocaleController.getString("AppName", R.string.AppName)).setMessage(error).setPositiveButton(R.string.OK, null).show();
.setTitle(LocaleController.getString("AppName", R.string.AppName))
.setMessage(error)
.setPositiveButton(R.string.OK, null)
.show();
} }
private void listRoots() { private void listRoots() {
@ -420,6 +420,7 @@ public class DocumentSelectActivity extends BaseFragment {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
AndroidUtilities.clearDrawableAnimation(listView);
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
} }
@ -465,35 +466,18 @@ public class DocumentSelectActivity extends BaseFragment {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { 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); ListItem item = items.get(position);
if (v == null) { if (item.icon != 0) {
v = View.inflate(mContext, R.layout.document_item, null); ((TextDetailDocumentsCell) convertView).setTextAndValueAndTypeAndThumb(item.title, item.subtitle, null, null, item.icon);
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);
} else { } else {
typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4))); String type = item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4));
imageView.setVisibility(View.GONE); ((TextDetailDocumentsCell) convertView).setTextAndValueAndTypeAndThumb(item.title, item.subtitle, type, item.thumb, 0);
typeTextView.setVisibility(View.VISIBLE);
} }
return v; return convertView;
} }
} }
} }

View File

@ -59,7 +59,11 @@ import java.util.HashMap;
public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { 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 int uid;
public XImageSpan(Drawable d, int verticalAlignment) { public XImageSpan(Drawable d, int verticalAlignment) {
@ -90,10 +94,14 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
private SectionsListView listView; private SectionsListView listView;
private ContactsSearchAdapter searchListViewAdapter; private ContactsSearchAdapter searchListViewAdapter;
private GroupCreateActivityDelegate delegate;
private int beforeChangeIndex; private int beforeChangeIndex;
private int maxCount = 200; private int maxCount = 200;
private boolean ignoreChange = false; private boolean ignoreChange = false;
private boolean isBroadcast = false; private boolean isBroadcast = false;
private boolean isAlwaysShare = false;
private boolean isNeverShare = false;
private boolean searchWas; private boolean searchWas;
private boolean searching; private boolean searching;
private CharSequence changeString; private CharSequence changeString;
@ -109,6 +117,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
public GroupCreateActivity(Bundle args) { public GroupCreateActivity(Bundle args) {
super(args); super(args);
isBroadcast = args.getBoolean("broadcast", false); isBroadcast = args.getBoolean("broadcast", false);
isAlwaysShare = args.getBoolean("isAlwaysShare", false);
isNeverShare = args.getBoolean("isNeverShare", false);
maxCount = !isBroadcast ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount; 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.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout); actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setTitle(isBroadcast ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList) : LocaleController.getString("NewGroup", R.string.NewGroup)); if (isAlwaysShare) {
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); 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() { actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override @Override
@ -145,9 +161,17 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (id == -1) { if (id == -1) {
finishFragment(); finishFragment();
} else if (id == done_button) { } else if (id == done_button) {
if (!selectedContacts.isEmpty()) { if (selectedContacts.isEmpty()) {
ArrayList<Integer> result = new ArrayList<Integer>(); return;
result.addAll(selectedContacts.keySet()); }
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(); Bundle args = new Bundle();
args.putIntegerArrayList("result", result); args.putIntegerArrayList("result", result);
args.putBoolean("broadcast", isBroadcast); args.putBoolean("broadcast", isBroadcast);
@ -157,7 +181,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
} }
}); });
ActionBarMenu menu = actionBar.createMenu(); 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 = new ContactsSearchAdapter(getParentActivity(), null, false);
searchListViewAdapter.setCheckedMap(selectedContacts); searchListViewAdapter.setCheckedMap(selectedContacts);
@ -179,8 +203,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
userSelectEditText = new EditText(getParentActivity()); userSelectEditText = new EditText(getParentActivity());
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
userSelectEditText.setHintTextColor(0xffa6a6a6); userSelectEditText.setHintTextColor(0xff979797);
userSelectEditText.setTextColor(0xff000000); userSelectEditText.setTextColor(0xff212121);
userSelectEditText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE); 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.setMinimumHeight(AndroidUtilities.dp(54));
userSelectEditText.setSingleLine(false); userSelectEditText.setSingleLine(false);
@ -201,7 +225,13 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams1.gravity = Gravity.TOP; layoutParams1.gravity = Gravity.TOP;
userSelectEditText.setLayoutParams(layoutParams1); userSelectEditText.setLayoutParams(layoutParams1);
userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo)); 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) { if (Build.VERSION.SDK_INT >= 11) {
userSelectEditText.setTextIsSelectable(false); userSelectEditText.setTextIsSelectable(false);
} }
@ -243,7 +273,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
selectedContacts.remove(sp.uid); selectedContacts.remove(sp.uid);
} }
} }
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); if (!isAlwaysShare && !isNeverShare) {
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
}
listView.invalidateViews(); listView.invalidateViews();
} else { } else {
search = true; search = true;
@ -288,27 +320,43 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
} }
}); });
emptyTextView = new TextView(getParentActivity()); LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextView.setTextColor(0xff808080); emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextView.setTextSize(24); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
emptyTextView.setGravity(Gravity.CENTER); linearLayout.addView(emptyTextLayout);
emptyTextView.setVisibility(View.INVISIBLE); layoutParams = (LinearLayout.LayoutParams) emptyTextLayout.getLayoutParams();
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
linearLayout.addView(emptyTextView); layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); emptyTextLayout.setLayoutParams(layoutParams);
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return true; 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);
layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams);
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 = new SectionsListView(getParentActivity());
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
@ -361,7 +409,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
span.uid = user.id; span.uid = user.id;
ignoreChange = false; ignoreChange = false;
} }
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); if (!isAlwaysShare && !isNeverShare) {
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
}
if (searching || searchWas) { if (searching || searchWas) {
ignoreChange = true; ignoreChange = true;
SpannableStringBuilder ssb = new SpannableStringBuilder(""); SpannableStringBuilder ssb = new SpannableStringBuilder("");
@ -400,6 +450,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
@Override @Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (absListView.isFastScrollEnabled()) {
AndroidUtilities.clearDrawableAnimation(absListView);
}
} }
}); });
} else { } 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); LayoutInflater lf = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View textView = lf.inflate(R.layout.group_create_bubble, null); View textView = lf.inflate(R.layout.group_create_bubble, null);
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view); TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);

View File

@ -184,7 +184,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}); });
ActionBarMenu menu = actionBar.createMenu(); 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()); fragmentView = new LinearLayout(getParentActivity());
LinearLayout linearLayout = (LinearLayout) fragmentView; LinearLayout linearLayout = (LinearLayout) fragmentView;
@ -198,6 +198,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
frameLayout.setLayoutParams(layoutParams); frameLayout.setLayoutParams(layoutParams);
avatarImage = new BackupImageView(getParentActivity()); avatarImage = new BackupImageView(getParentActivity());
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable.setInfo(5, null, null, isBroadcast); avatarDrawable.setInfo(5, null, null, isBroadcast);
avatarImage.setImageDrawable(avatarDrawable); avatarImage.setImageDrawable(avatarDrawable);
frameLayout.addView(avatarImage); frameLayout.addView(avatarImage);
@ -254,12 +255,12 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
nameTextView.setMaxLines(4); nameTextView.setMaxLines(4);
nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
nameTextView.setHintTextColor(0xffa6a6a6); nameTextView.setHintTextColor(0xff979797);
nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8)); nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
AndroidUtilities.clearCursorDrawable(nameTextView); AndroidUtilities.clearCursorDrawable(nameTextView);
nameTextView.setTextColor(0xff000000); nameTextView.setTextColor(0xff212121);
frameLayout.addView(nameTextView); frameLayout.addView(nameTextView);
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;

View File

@ -20,6 +20,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -94,7 +95,6 @@ public class LanguageSelectActivity extends BaseFragment {
if (text.length() != 0) { if (text.length() != 0) {
searchWas = true; searchWas = true;
if (listView != null) { if (listView != null) {
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
listView.setAdapter(searchListViewAdapter); listView.setAdapter(searchListViewAdapter);
} }
} }
@ -106,27 +106,44 @@ public class LanguageSelectActivity extends BaseFragment {
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(getParentActivity());
emptyTextView = new TextView(getParentActivity()); LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
emptyTextView.setTextColor(0xff808080); emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextView.setTextSize(24); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
emptyTextView.setGravity(Gravity.CENTER); ((FrameLayout) fragmentView).addView(emptyTextLayout);
emptyTextView.setVisibility(View.INVISIBLE); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
((FrameLayout) fragmentView).addView(emptyTextView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP; layoutParams.gravity = Gravity.TOP;
emptyTextView.setLayoutParams(layoutParams); emptyTextLayout.setLayoutParams(layoutParams);
emptyTextView.setOnTouchListener(new View.OnTouchListener() { emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return true; 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 = new ListView(getParentActivity());
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);

View File

@ -0,0 +1,469 @@
/*
* 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;
}
}
}

View File

@ -0,0 +1,313 @@
/*
* 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();
}
}
}

View File

@ -27,11 +27,11 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
@ -61,28 +61,28 @@ import java.util.ArrayList;
import java.util.Map; import java.util.Map;
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate { public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate {
private boolean finished = false; private boolean finished;
private String videoPath = null; private String videoPath;
private String sendingText = null; private String sendingText;
private ArrayList<Uri> photoPathsArray = null; private ArrayList<Uri> photoPathsArray;
private ArrayList<String> documentsPathsArray = null; private ArrayList<String> documentsPathsArray;
private ArrayList<String> documentsOriginalPathsArray = null; private ArrayList<String> documentsOriginalPathsArray;
private ArrayList<TLRPC.User> contactsToSend = null; private ArrayList<TLRPC.User> contactsToSend;
private int currentConnectionState; private int currentConnectionState;
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<BaseFragment>(); private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<BaseFragment>();
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<BaseFragment>(); private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<BaseFragment>();
private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<BaseFragment>(); private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<BaseFragment>();
private ActionBarLayout actionBarLayout = null; private ActionBarLayout actionBarLayout;
private ActionBarLayout layersActionBarLayout = null; private ActionBarLayout layersActionBarLayout;
private ActionBarLayout rightActionBarLayout = null; private ActionBarLayout rightActionBarLayout;
private FrameLayout shadowTablet = null; private FrameLayout shadowTablet;
private LinearLayout buttonLayoutTablet = null; private FrameLayout shadowTabletSide;
private FrameLayout shadowTabletSide = null; private ImageView backgroundTablet;
private ImageView backgroundTablet = null; private DrawerLayoutContainer drawerLayoutContainer;
private DrawerLayoutContainer drawerLayoutContainer = null; private DrawerLayoutAdapter drawerLayoutAdapter;
private boolean tabletFullSize = false; private boolean tabletFullSize;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -114,14 +114,66 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
actionBarLayout = new ActionBarLayout(this); int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (AndroidUtilities.isTablet()) { if (resourceId > 0) {
setContentView(R.layout.launch_layout_tablet); AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
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);
actionBarLayout = new ActionBarLayout(this);
drawerLayoutContainer = new DrawerLayoutContainer(this);
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (AndroidUtilities.isTablet()) {
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() { shadowTablet.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
@ -157,176 +209,105 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
}); });
RelativeLayout launchLayout = (RelativeLayout)findViewById(R.id.launch_layout);
layersActionBarLayout = new ActionBarLayout(this); layersActionBarLayout = new ActionBarLayout(this);
layersActionBarLayout.setRemoveActionBarExtraHeight(true);
layersActionBarLayout.setBackgroundView(shadowTablet); layersActionBarLayout.setBackgroundView(shadowTablet);
layersActionBarLayout.setUseAlphaAnimations(true); layersActionBarLayout.setUseAlphaAnimations(true);
layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow); layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
launchLayout.addView(layersActionBarLayout); launchLayout.addView(layersActionBarLayout);
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams(); relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
relativeLayoutParams.width = AndroidUtilities.dp(498); relativeLayoutParams.width = AndroidUtilities.dp(498);
relativeLayoutParams.height = AndroidUtilities.dp(528); relativeLayoutParams.height = AndroidUtilities.dp(528);
relativeLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
layersActionBarLayout.setLayoutParams(relativeLayoutParams); layersActionBarLayout.setLayoutParams(relativeLayoutParams);
layersActionBarLayout.init(layerFragmentsStack); layersActionBarLayout.init(layerFragmentsStack);
layersActionBarLayout.setDelegate(this); layersActionBarLayout.setDelegate(this);
layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
layersActionBarLayout.setVisibility(View.GONE); layersActionBarLayout.setVisibility(View.GONE);
} else {
drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
launchLayout.addView(actionBarLayout, 2); ListView listView = new ListView(this);
relativeLayoutParams = (RelativeLayout.LayoutParams)actionBarLayout.getLayoutParams(); listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this));
relativeLayoutParams.width = AndroidUtilities.dp(320); drawerLayoutContainer.setDrawerLayout(listView);
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; listView.setBackgroundColor(0xffffffff);
actionBarLayout.setLayoutParams(relativeLayoutParams); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)listView.getLayoutParams();
Point screenSize = AndroidUtilities.getRealScreenSize();
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);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setLayoutParams(layoutParams);
listView.setVerticalScrollBarEnabled(false);
rightActionBarLayout = new ActionBarLayout(this); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
launchLayout.addView(rightActionBarLayout, 3); @Override
relativeLayoutParams = (RelativeLayout.LayoutParams)rightActionBarLayout.getLayoutParams(); public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
relativeLayoutParams.width = AndroidUtilities.dp(320); if (position == 2) {
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()); presentFragment(new GroupCreateActivity());
} drawerLayoutContainer.closeDrawer(false);
}); } else if (position == 3) {
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(); Bundle args = new Bundle();
args.putBoolean("onlyUsers", true); args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true); args.putBoolean("destroyAfterSelect", true);
args.putBoolean("createSecretChat", true); args.putBoolean("createSecretChat", true);
presentFragment(new ContactsActivity(args)); presentFragment(new ContactsActivity(args));
} drawerLayoutContainer.closeDrawer(false);
}); } else if (position == 4) {
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(); Bundle args = new Bundle();
args.putBoolean("broadcast", true); args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args)); presentFragment(new GroupCreateActivity(args));
} drawerLayoutContainer.closeDrawer(false);
}); } else if (position == 6) {
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)); presentFragment(new ContactsActivity(null));
} drawerLayoutContainer.closeDrawer(false);
}); } else if (position == 7) {
try {
button = (TextView)findViewById(R.id.settings_button); Intent intent = new Intent(Intent.ACTION_SEND);
button.setText(LocaleController.getString("Settings", R.string.Settings)); intent.setType("text/plain");
button.setOnClickListener(new View.OnClickListener() { intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText());
@Override startActivity(intent);
public void onClick(View v) { } catch (Exception e) {
presentFragment(new SettingsActivity()); FileLog.e("tmessages", e);
}
});
} 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));
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.height = FrameLayout.LayoutParams.MATCH_PARENT;
listView.setPadding(0, 0, 0, 0);
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setLayoutParams(layoutParams);
listView.setVerticalScrollBarEnabled(false);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 2) {
presentFragment(new GroupCreateActivity());
drawerLayoutContainer.closeDrawer(false);
} else if (position == 3) {
Bundle args = new Bundle();
args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true);
args.putBoolean("createSecretChat", true);
presentFragment(new ContactsActivity(args));
drawerLayoutContainer.closeDrawer(false);
} else if (position == 4) {
Bundle args = new Bundle();
args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args));
drawerLayoutContainer.closeDrawer(false);
} else if (position == 6) {
presentFragment(new ContactsActivity(null));
drawerLayoutContainer.closeDrawer(false);
} else if (position == 7) {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText());
startActivity(intent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
drawerLayoutContainer.closeDrawer(false);
} else if (position == 8) {
presentFragment(new SettingsActivity());
drawerLayoutContainer.closeDrawer(false);
} else if (position == 9) {
try {
Intent pickIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)));
startActivity(pickIntent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
drawerLayoutContainer.closeDrawer(false);
} }
drawerLayoutContainer.closeDrawer(false);
} else if (position == 8) {
presentFragment(new SettingsActivity());
drawerLayoutContainer.closeDrawer(false);
} else if (position == 9) {
try {
Intent pickIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)));
startActivity(pickIntent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
drawerLayoutContainer.closeDrawer(false);
} }
}); }
});
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout); actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
}
actionBarLayout.init(mainFragmentsStack); actionBarLayout.init(mainFragmentsStack);
actionBarLayout.setDelegate(this); 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); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
currentConnectionState = ConnectionsManager.getInstance().getConnectionState(); currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
if (actionBarLayout.fragmentsStack.isEmpty()) { if (actionBarLayout.fragmentsStack.isEmpty()) {
if (!UserConfig.isClientActivated()) { if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity()); actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false);
} else { } else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null)); actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true);
} }
try { try {
@ -672,18 +653,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (UserConfig.isClientActivated()) { if (UserConfig.isClientActivated()) {
if (actionBarLayout.fragmentsStack.isEmpty()) { if (actionBarLayout.fragmentsStack.isEmpty()) {
actionBarLayout.addFragmentToStack(new MessagesActivity(null)); actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true);
} }
} else { } else {
if (layersActionBarLayout.fragmentsStack.isEmpty()) { if (layersActionBarLayout.fragmentsStack.isEmpty()) {
layersActionBarLayout.addFragmentToStack(new LoginActivity()); layersActionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false);
} }
} }
} else { } else {
if (actionBarLayout.fragmentsStack.isEmpty()) { if (actionBarLayout.fragmentsStack.isEmpty()) {
if (!UserConfig.isClientActivated()) { if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity()); actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false);
} else { } else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null)); actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true);
} }
} }
} }
@ -781,6 +766,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
finished = true; finished = true;
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState);
} }
@ -795,6 +781,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
public void needLayout() { public void needLayout() {
if (AndroidUtilities.isTablet()) { 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) { if (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
tabletFullSize = false; tabletFullSize = false;
int leftWidth = AndroidUtilities.displaySize.x / 100 * 35; int leftWidth = AndroidUtilities.displaySize.x / 100 * 35;
@ -802,7 +795,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
leftWidth = AndroidUtilities.dp(320); leftWidth = AndroidUtilities.dp(320);
} }
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams.width = leftWidth; relativeLayoutParams.width = leftWidth;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(relativeLayoutParams); actionBarLayout.setLayoutParams(relativeLayoutParams);
@ -817,12 +810,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
relativeLayoutParams.leftMargin = leftWidth; relativeLayoutParams.leftMargin = leftWidth;
rightActionBarLayout.setLayoutParams(relativeLayoutParams); 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) { if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) {
BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1); BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1);
chatFragment.onPause(); chatFragment.onPause();
@ -833,13 +820,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
rightActionBarLayout.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE); 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); backgroundTablet.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
shadowTabletSide.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE); shadowTabletSide.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
} else { } else {
tabletFullSize = true; tabletFullSize = true;
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(relativeLayoutParams); actionBarLayout.setLayoutParams(relativeLayoutParams);
@ -847,7 +833,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
shadowTabletSide.setVisibility(View.GONE); shadowTabletSide.setVisibility(View.GONE);
rightActionBarLayout.setVisibility(View.GONE); rightActionBarLayout.setVisibility(View.GONE);
backgroundTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE); backgroundTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
buttonLayoutTablet.setVisibility(View.GONE);
if (rightActionBarLayout.fragmentsStack.size() == 1) { if (rightActionBarLayout.fragmentsStack.size() == 1) {
BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0); BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0);
@ -974,6 +959,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
currentConnectionState = state; currentConnectionState = state;
//actionBarLayout.getActionBar().setBackOverlayVisible(currentConnectionState != 0); //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 @Override
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) { public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE);
if (fragment instanceof MessagesActivity) { if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment; MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.getDelegate() == null && layout != actionBarLayout) { if (messagesActivity.getDelegate() == null && layout != actionBarLayout) {
@ -1127,10 +1114,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false); actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
layersActionBarLayout.removeAllFragments(); layersActionBarLayout.removeAllFragments();
layersActionBarLayout.setVisibility(View.GONE); layersActionBarLayout.setVisibility(View.GONE);
drawerLayoutContainer.setAllowOpenDrawer(true);
if (!tabletFullSize) { if (!tabletFullSize) {
shadowTabletSide.setVisibility(View.VISIBLE); shadowTabletSide.setVisibility(View.VISIBLE);
if (rightActionBarLayout.fragmentsStack.isEmpty()) { if (rightActionBarLayout.fragmentsStack.isEmpty()) {
buttonLayoutTablet.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
} }
} }
@ -1140,7 +1127,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (fragment instanceof ChatActivity) { if (fragment instanceof ChatActivity) {
if (!tabletFullSize && layout != rightActionBarLayout) { if (!tabletFullSize && layout != rightActionBarLayout) {
rightActionBarLayout.setVisibility(View.VISIBLE); rightActionBarLayout.setVisibility(View.VISIBLE);
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.GONE); backgroundTablet.setVisibility(View.GONE);
rightActionBarLayout.removeAllFragments(); rightActionBarLayout.removeAllFragments();
rightActionBarLayout.presentFragment(fragment, removeLast, true, false); rightActionBarLayout.presentFragment(fragment, removeLast, true, false);
@ -1177,8 +1163,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
} else if (layout != layersActionBarLayout) { } else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE); layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false);
if (fragment instanceof LoginActivity) { if (fragment instanceof LoginActivity) {
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE); shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000); shadowTablet.setBackgroundColor(0x00000000);
@ -1190,14 +1176,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
return true; return true;
} else { } else {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
return true; return true;
} }
} }
@Override @Override
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) { public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE);
if (fragment instanceof MessagesActivity) { if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment; MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.getDelegate() == null && layout != actionBarLayout) { if (messagesActivity.getDelegate() == null && layout != actionBarLayout) {
@ -1205,10 +1192,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.addFragmentToStack(fragment); actionBarLayout.addFragmentToStack(fragment);
layersActionBarLayout.removeAllFragments(); layersActionBarLayout.removeAllFragments();
layersActionBarLayout.setVisibility(View.GONE); layersActionBarLayout.setVisibility(View.GONE);
drawerLayoutContainer.setAllowOpenDrawer(true);
if (!tabletFullSize) { if (!tabletFullSize) {
shadowTabletSide.setVisibility(View.VISIBLE); shadowTabletSide.setVisibility(View.VISIBLE);
if (rightActionBarLayout.fragmentsStack.isEmpty()) { if (rightActionBarLayout.fragmentsStack.isEmpty()) {
buttonLayoutTablet.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
} }
} }
@ -1217,7 +1204,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (fragment instanceof ChatActivity) { } else if (fragment instanceof ChatActivity) {
if (!tabletFullSize && layout != rightActionBarLayout) { if (!tabletFullSize && layout != rightActionBarLayout) {
rightActionBarLayout.setVisibility(View.VISIBLE); rightActionBarLayout.setVisibility(View.VISIBLE);
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.GONE); backgroundTablet.setVisibility(View.GONE);
rightActionBarLayout.removeAllFragments(); rightActionBarLayout.removeAllFragments();
rightActionBarLayout.addFragmentToStack(fragment); rightActionBarLayout.addFragmentToStack(fragment);
@ -1242,8 +1228,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
} else if (layout != layersActionBarLayout) { } else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE); layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false);
if (fragment instanceof LoginActivity) { if (fragment instanceof LoginActivity) {
buttonLayoutTablet.setVisibility(View.GONE);
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE); shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000); shadowTablet.setBackgroundColor(0x00000000);
@ -1255,6 +1241,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
return true; return true;
} else { } else {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity));
return true; return true;
} }
} }
@ -1268,7 +1255,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
return false; return false;
} else if (layout == rightActionBarLayout) { } else if (layout == rightActionBarLayout) {
if (!tabletFullSize) { if (!tabletFullSize) {
buttonLayoutTablet.setVisibility(View.VISIBLE);
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
} }
} else if (layout == layersActionBarLayout && actionBarLayout.fragmentsStack.isEmpty() && layersActionBarLayout.fragmentsStack.size() == 1) { } 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(); rightActionBarLayout.showLastFragment();
actionBarLayout.rebuildAllFragmentViews(true); actionBarLayout.rebuildAllFragmentViews(true);
actionBarLayout.showLastFragment(); 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));
} }
} }
} }

View File

@ -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.Marker;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; 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); avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view);
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.processDetach = false; avatarImageView.processDetach = false;
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
} }
nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label); nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label);
distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label); distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label);

View File

@ -117,7 +117,7 @@ public class LoginActivity extends BaseFragment {
}); });
ActionBarMenu menu = actionBar.createMenu(); 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()); fragmentView = new ScrollView(getParentActivity());
ScrollView scrollView = (ScrollView) fragmentView; ScrollView scrollView = (ScrollView) fragmentView;
@ -207,13 +207,17 @@ public class LoginActivity extends BaseFragment {
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); if (!AndroidUtilities.isTablet()) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
} }
private Bundle loadCurrentState() { private Bundle loadCurrentState() {
@ -411,6 +415,7 @@ public class LoginActivity extends BaseFragment {
public void needFinishActivity() { public void needFinishActivity() {
clearCurrentState(); clearCurrentState();
presentFragment(new MessagesActivity(null), true); presentFragment(new MessagesActivity(null), true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
} }
public class SlideView extends LinearLayout { public class SlideView extends LinearLayout {
@ -989,7 +994,7 @@ public class LoginActivity extends BaseFragment {
codeField.setHintTextColor(0xff979797); codeField.setHintTextColor(0xff979797);
codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
codeField.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); codeField.setInputType(InputType.TYPE_CLASS_NUMBER);
codeField.setMaxLines(1); codeField.setMaxLines(1);
codeField.setPadding(0, 0, 0, 0); codeField.setPadding(0, 0, 0, 0);
addView(codeField); addView(codeField);

View File

@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
public class MediaActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider { public class MediaActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
private GridView listView; private GridView listView;
private ListAdapter listAdapter; private ListAdapter listAdapter;
private ArrayList<MessageObject> messages = new ArrayList<MessageObject>(); private ArrayList<MessageObject> messages = new ArrayList<MessageObject>();

View File

@ -58,7 +58,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private ListView messagesListView; private ListView messagesListView;
private DialogsAdapter dialogsAdapter; private DialogsAdapter dialogsAdapter;
private DialogsSearchAdapter dialogsSearchAdapter; private DialogsSearchAdapter dialogsSearchAdapter;
private TextView searchEmptyView; private View searchEmptyView;
private View progressView; private View progressView;
private View emptyView; private View emptyView;
private ImageView floatingButton; private ImageView floatingButton;
@ -243,14 +243,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
progressView = fragmentView.findViewById(R.id.progressLayout); progressView = fragmentView.findViewById(R.id.progressLayout);
dialogsAdapter.notifyDataSetChanged(); dialogsAdapter.notifyDataSetChanged();
searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); searchEmptyView = fragmentView.findViewById(R.id.search_empty_view);
searchEmptyView.setOnTouchListener(new View.OnTouchListener() { searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return true; return true;
} }
}); });
searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView = fragmentView.findViewById(R.id.list_empty_view); emptyView = fragmentView.findViewById(R.id.list_empty_view);
emptyView.setOnTouchListener(new View.OnTouchListener() { emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
@ -258,10 +257,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
return true; return true;
} }
}); });
TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1); TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
textView.setText(LocaleController.getString("NoChats", R.string.NoChats)); textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2); 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 = (ImageView)fragmentView.findViewById(R.id.floating_button);
floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE); floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
@ -393,56 +396,40 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
int lower_id = (int)selectedDialog; int lower_id = (int)selectedDialog;
int high_id = (int)(selectedDialog >> 32); int high_id = (int)(selectedDialog >> 32);
if (lower_id < 0 && high_id != 1) { final boolean isChat = 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() { builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory),
@Override isChat ? LocaleController.getString("DeleteChat", R.string.DeleteChat) : LocaleController.getString("Delete", R.string.Delete)}, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
if (which == 0) { public void onClick(DialogInterface dialog, final int which) {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, true); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
} else if (which == 1) { builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (which == 0) {
builder.setMessage(LocaleController.getString("AreYouSureClearHistory", R.string.AreYouSureClearHistory));
} else {
if (isChat) {
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit)); 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);
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureDeleteThisChat", R.string.AreYouSureDeleteThisChat)); 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);
if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} }
} }
}); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
} @Override
public void onClick(DialogInterface dialogInterface, int i) {
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); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder); showAlertDialog(builder);
return true; return true;
@ -545,14 +532,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
emptyView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
messagesListView.setEmptyView(progressView); messagesListView.setEmptyView(progressView);
} else { } else {
if (messagesListView.getEmptyView() == null) { if (searching && searchWas) {
if (searching && searchWas) { messagesListView.setEmptyView(searchEmptyView);
messagesListView.setEmptyView(searchEmptyView); emptyView.setVisibility(View.GONE);
emptyView.setVisibility(View.GONE); } else {
} else { messagesListView.setEmptyView(emptyView);
messagesListView.setEmptyView(emptyView); searchEmptyView.setVisibility(View.GONE);
searchEmptyView.setVisibility(View.GONE);
}
} }
progressView.setVisibility(View.GONE); progressView.setVisibility(View.GONE);
} }

View File

@ -353,7 +353,7 @@ public class PhotoCropActivity extends BaseFragment {
}); });
ActionBarMenu menu = actionBar.createMenu(); 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 = view = new PhotoCropView(getParentActivity());
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));

View File

@ -76,6 +76,7 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
private int classGuid; private int classGuid;
private PhotoViewerProvider placeProvider; private PhotoViewerProvider placeProvider;
private boolean isVisible; private boolean isVisible;
@ -325,6 +326,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
public int user_id; public int user_id;
public int index; public int index;
public int size; public int size;
public int radius;
} }
public static interface PhotoViewerProvider { public static interface PhotoViewerProvider {
@ -602,6 +604,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
actionBar = new ActionBar(activity); actionBar = new ActionBar(activity);
actionBar.setBackgroundColor(0x7F000000); actionBar.setBackgroundColor(0x7F000000);
actionBar.setOccupyStatusBar(false);
actionBar.setItemsBackground(R.drawable.bar_selector_white); actionBar.setItemsBackground(R.drawable.bar_selector_white);
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); 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(); final Rect drawRegion = object.imageReceiver.getDrawRegion();
animatingImageView.setVisibility(View.VISIBLE); animatingImageView.setVisibility(View.VISIBLE);
animatingImageView.setRadius(object.radius);
animatingImageView.setNeedRadius(object.radius != 0);
animatingImageView.setImageBitmap(object.thumb); animatingImageView.setImageBitmap(object.thumb);
ViewProxy.setAlpha(animatingImageView, 1.0f); ViewProxy.setAlpha(animatingImageView, 1.0f);
@ -1643,6 +1648,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal, 0), ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal, 0),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop, 0), ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop, 0),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom, 0), ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom, 0),
ObjectAnimatorProxy.ofInt(animatingImageView, "radius", 0),
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f) ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f)
); );
@ -1731,11 +1737,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
Rect drawRegion = null; Rect drawRegion = null;
if (object != null) { if (object != null) {
animatingImageView.setNeedRadius(object.radius != 0);
drawRegion = object.imageReceiver.getDrawRegion(); drawRegion = object.imageReceiver.getDrawRegion();
layoutParams.width = drawRegion.right - drawRegion.left; layoutParams.width = drawRegion.right - drawRegion.left;
layoutParams.height = drawRegion.bottom - drawRegion.top; layoutParams.height = drawRegion.bottom - drawRegion.top;
animatingImageView.setImageBitmap(object.thumb); animatingImageView.setImageBitmap(object.thumb);
} else { } else {
animatingImageView.setNeedRadius(false);
layoutParams.width = centerImage.getImageWidth(); layoutParams.width = centerImage.getImageWidth();
layoutParams.height = centerImage.getImageHeight(); layoutParams.height = centerImage.getImageHeight();
animatingImageView.setImageBitmap(centerImage.getBitmap()); animatingImageView.setImageBitmap(centerImage.getBitmap());
@ -1782,6 +1790,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal), ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop), ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop),
ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom), ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom),
ObjectAnimatorProxy.ofInt(animatingImageView, "radius", object.radius),
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f) ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f)
); );
} else { } else {

View File

@ -15,6 +15,7 @@ import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -61,6 +62,9 @@ public class PopupNotificationActivity extends Activity implements NotificationC
private ActionBar actionBar; private ActionBar actionBar;
private ChatActivityEnterView chatActivityEnterView; private ChatActivityEnterView chatActivityEnterView;
private BackupImageView avatarImageView; private BackupImageView avatarImageView;
private TextView nameTextView;
private TextView onlineTextView;
private FrameLayout avatarContainer;
private TextView countText; private TextView countText;
private ViewGroup messageContainer; private ViewGroup messageContainer;
private ViewGroup centerView; private ViewGroup centerView;
@ -182,6 +186,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
popupContainer.addView(messageContainer, 0); popupContainer.addView(messageContainer, 0);
actionBar = new ActionBar(this); actionBar = new ActionBar(this);
actionBar.setOccupyStatusBar(false);
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackgroundResource(R.color.header); actionBar.setBackgroundResource(R.color.header);
actionBar.setItemsBackground(R.drawable.bar_selector); 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); View view = menu.addItemResource(2, R.layout.popup_count_layout);
countText = (TextView) view.findViewById(R.id.count_text); countText = (TextView) view.findViewById(R.id.count_text);
view = menu.addItemResource(1, R.layout.chat_header_layout); avatarContainer = new FrameLayoutFixed(this);
avatarImageView = (BackupImageView)view.findViewById(R.id.chat_avatar_image); 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; 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() { actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override @Override
@ -616,22 +674,37 @@ public class PopupNotificationActivity extends Activity implements NotificationC
} }
private void fixLayout() { private void fixLayout() {
messageContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { if (avatarContainer != null) {
@Override avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() { @Override
messageContainer.getViewTreeObserver().removeOnPreDrawListener(this); public boolean onPreDraw() {
if (!checkTransitionAnimation() && !startedMoving) { if (avatarContainer != null) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)messageContainer.getLayoutParams(); avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this);
layoutParams.topMargin = AndroidUtilities.getCurrentActionBarHeight(); }
layoutParams.bottomMargin = AndroidUtilities.dp(48); int padding = (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT; avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
layoutParams.height = ViewGroup.MarginLayoutParams.MATCH_PARENT; return false;
messageContainer.setLayoutParams(layoutParams);
applyViewsLayoutParams(0);
} }
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();
layoutParams.topMargin = AndroidUtilities.getCurrentActionBarHeight();
layoutParams.bottomMargin = AndroidUtilities.dp(48);
layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
layoutParams.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
messageContainer.setLayoutParams(layoutParams);
applyViewsLayoutParams(0);
}
return false;
}
});
}
} }
private void handleIntent(Intent intent) { private void handleIntent(Intent intent) {
@ -732,15 +805,18 @@ public class PopupNotificationActivity extends Activity implements NotificationC
} }
if (currentChat != null && currentUser != null) { if (currentChat != null && currentUser != null) {
actionBar.setTitle(currentChat.title); nameTextView.setText(currentChat.title);
actionBar.setSubtitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); onlineTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
actionBar.setTitleIcon(0, 0); nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
nameTextView.setCompoundDrawablePadding(0);
} else if (currentUser != null) { } 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) { 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 { } 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.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) { if (currentUser.phone != null && currentUser.phone.length() != 0) {
actionBar.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else { } else {
actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
} }
} else { } 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()); CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
if (printString == null || printString.length() == 0) { if (printString == null || printString.length() == 0) {
@ -774,10 +850,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (user != null) { if (user != null) {
currentUser = user; currentUser = user;
} }
actionBar.setSubtitle(LocaleController.formatUserStatus(currentUser)); onlineTextView.setText(LocaleController.formatUserStatus(currentUser));
} else { } else {
lastPrintString = printString; lastPrintString = printString;
actionBar.setSubtitle(printString); onlineTextView.setText(printString);
setTypingAnimation(true); setTypingAnimation(true);
} }
} }
@ -817,13 +893,15 @@ public class PopupNotificationActivity extends Activity implements NotificationC
} }
if (start) { if (start) {
try { try {
actionBar.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4)); onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null);
onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
typingDotsDrawable.start(); typingDotsDrawable.start();
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else { } else {
actionBar.setSubTitleIcon(0, null, 0); onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
onlineTextView.setCompoundDrawablePadding(0);
typingDotsDrawable.stop(); typingDotsDrawable.stop();
} }
} }

View File

@ -8,7 +8,427 @@
package org.telegram.ui; package org.telegram.ui;
import org.telegram.ui.ActionBar.BaseFragment; 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;
public class PrivacySettingsActivity extends BaseFragment { 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;
}
@Override
public boolean isEmpty() {
return false;
}
}
} }

View File

@ -224,6 +224,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout); actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false); actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override @Override
public void onItemClick(final int id) { public void onItemClick(final int id) {
@ -675,7 +678,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
FrameLayout.LayoutParams layoutParams; FrameLayout.LayoutParams layoutParams;
if (listView != null) { if (listView != null) {
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); 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); listView.setLayoutParams(layoutParams);
} }
@ -694,7 +697,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (writeButton != null) { if (writeButton != null) {
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); 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); writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff); ViewProxy.setAlpha(writeButton, diff);
writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE); 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.user_id = user_id;
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
object.size = -1; object.size = -1;
object.radius = avatarImage.imageReceiver.getRoundRadius();
return object; return object;
} }
return null; return null;
@ -1019,6 +1023,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
private void updateProfileData() { private void updateProfileData() {
if (avatarImage == null) {
return;
}
if (user_id != 0) { if (user_id != 0) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id); TLRPC.User user = MessagesController.getInstance().getUser(user_id);
TLRPC.FileLocation photo = null; TLRPC.FileLocation photo = null;
@ -1219,7 +1226,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
view = new TextCell(mContext); view = new TextCell(mContext);
} }
TextCell textCell = (TextCell) view; TextCell textCell = (TextCell) view;
textCell.setTextColor(0xff000000); textCell.setTextColor(0xff212121);
if (i == sharedMediaRow) { if (i == sharedMediaRow) {
String value; String value;

View File

@ -38,7 +38,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
@ -101,10 +100,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
private int settingsSectionRow2; private int settingsSectionRow2;
private int enableAnimationsRow; private int enableAnimationsRow;
private int notificationRow; private int notificationRow;
private int blockedRow;
private int backgroundRow; private int backgroundRow;
private int languageRow; private int languageRow;
private int terminateSessionsRow; private int privacyRow;
private int mediaDownloadSection; private int mediaDownloadSection;
private int mediaDownloadSection2; private int mediaDownloadSection2;
private int mobileDownloadRow; private int mobileDownloadRow;
@ -194,6 +192,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public void run() { public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL); NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
UserConfig.saveConfig(true); UserConfig.saveConfig(true);
} }
}); });
@ -214,10 +213,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
settingsSectionRow2 = rowCount++; settingsSectionRow2 = rowCount++;
enableAnimationsRow = rowCount++; enableAnimationsRow = rowCount++;
notificationRow = rowCount++; notificationRow = rowCount++;
blockedRow = rowCount++; privacyRow = rowCount++;
backgroundRow = rowCount++; backgroundRow = rowCount++;
languageRow = rowCount++; languageRow = rowCount++;
terminateSessionsRow = rowCount++;
mediaDownloadSection = rowCount++; mediaDownloadSection = rowCount++;
mediaDownloadSection2 = rowCount++; mediaDownloadSection2 = rowCount++;
mobileDownloadRow = rowCount++; mobileDownloadRow = rowCount++;
@ -268,6 +266,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout); actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false); actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override @Override
public void onItemClick(int id) { public void onItemClick(int id) {
@ -303,7 +304,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} }
}); });
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.clearItems();
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0); item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0);
item.addSubItem(logout, LocaleController.getString("LogOut", R.string.LogOut), 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) { } else if (i == notificationRow) {
presentFragment(new NotificationsSettingsActivity()); presentFragment(new NotificationsSettingsActivity());
} else if (i == blockedRow) {
presentFragment(new BlockedUsersActivity());
} else if (i == backgroundRow) { } else if (i == backgroundRow) {
presentFragment(new WallpapersActivity()); presentFragment(new WallpapersActivity());
} else if (i == askQuestionRow) { } else if (i == askQuestionRow) {
@ -467,46 +465,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (listView != null) { if (listView != null) {
listView.invalidateViews(); listView.invalidateViews();
} }
} else if (i == terminateSessionsRow) { } else if (i == privacyRow) {
if (getParentActivity() == null) { presentFragment(new PrivacySettingsActivity());
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 == languageRow) { } else if (i == languageRow) {
presentFragment(new LanguageSelectActivity()); presentFragment(new LanguageSelectActivity());
} else if (i == switchBackendButtonRow) { } else if (i == switchBackendButtonRow) {
@ -745,6 +705,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
object.user_id = UserConfig.getClientUserId(); object.user_id = UserConfig.getClientUserId();
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
object.size = -1; object.size = -1;
object.radius = avatarImage.imageReceiver.getRoundRadius();
return object; return object;
} }
} }
@ -903,7 +864,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
FrameLayout.LayoutParams layoutParams; FrameLayout.LayoutParams layoutParams;
if (listView != null) { if (listView != null) {
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); 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); listView.setLayoutParams(layoutParams);
} }
@ -921,7 +882,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm); int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm);
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); 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); writeButton.setLayoutParams(layoutParams);
ViewProxy.setAlpha(writeButton, diff); ViewProxy.setAlpha(writeButton, diff);
writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE); writeButton.setVisibility(diff == 0 ? View.GONE : View.VISIBLE);
@ -1021,8 +982,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public boolean isEnabled(int i) { public boolean isEnabled(int i) {
return i == textSizeRow || i == enableAnimationsRow || i == blockedRow || i == notificationRow || i == backgroundRow || return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow ||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == wifiDownloadRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == privacyRow || i == wifiDownloadRow ||
i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow || i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow ||
i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow; 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); int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
textCell.setTextAndValue(LocaleController.getString("TextSize", R.string.TextSize), String.format("%d", size), true); textCell.setTextAndValue(LocaleController.getString("TextSize", R.string.TextSize), String.format("%d", size), true);
} else if (i == languageRow) { } 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) { } else if (i == contactsSortRow) {
String value; String value;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); 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); textCell.setTextAndValue(LocaleController.getString("SortBy", R.string.SortBy), value, true);
} else if (i == notificationRow) { } else if (i == notificationRow) {
textCell.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), true); 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) { } else if (i == backgroundRow) {
textCell.setText(LocaleController.getString("ChatBackground", R.string.ChatBackground), true); textCell.setText(LocaleController.getString("ChatBackground", R.string.ChatBackground), true);
} else if (i == sendLogsRow) { } else if (i == sendLogsRow) {
@ -1098,8 +1057,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
textCell.setText("Clear Logs", true); textCell.setText("Clear Logs", true);
} else if (i == askQuestionRow) { } else if (i == askQuestionRow) {
textCell.setText(LocaleController.getString("AskAQuestion", R.string.AskAQuestion), true); textCell.setText(LocaleController.getString("AskAQuestion", R.string.AskAQuestion), true);
} else if (i == terminateSessionsRow) { } else if (i == privacyRow) {
textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false); textCell.setText(LocaleController.getString("PrivacySettings", R.string.PrivacySettings), true);
} else if (i == switchBackendButtonRow) { } else if (i == switchBackendButtonRow) {
textCell.setText("Switch Backend", true); textCell.setText("Switch Backend", true);
} else if (i == telegramFaqRow) { } else if (i == telegramFaqRow) {
@ -1223,7 +1182,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
return 1; return 1;
} else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow) { } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow) {
return 3; 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; return 2;
} else if (i == versionRow) { } else if (i == versionRow) {
return 5; return 5;

View File

@ -254,7 +254,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
}); });
ActionBarMenu menu = actionBar.createMenu(); 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); fragmentView = inflater.inflate(R.layout.video_editor_layout, container, false);
originalSizeTextView = (TextView) fragmentView.findViewById(R.id.original_size); originalSizeTextView = (TextView) fragmentView.findViewById(R.id.original_size);

View File

@ -8,15 +8,10 @@
package org.telegram.ui.Views; 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.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build;
import android.os.PowerManager; import android.os.PowerManager;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
@ -48,10 +43,12 @@ import org.telegram.messenger.FileLog;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; 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 org.telegram.ui.ApplicationLoader;
import java.util.ArrayList;
public class ChatActivityEnterView implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate { public class ChatActivityEnterView implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate {
public static interface ChatActivityEnterViewDelegate { public static interface ChatActivityEnterViewDelegate {
@ -71,7 +68,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout; private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
private FrameLayout attachButton; private FrameLayout attachButton;
private Object runningAnimation; private AnimatorSetProxy runningAnimation;
private AnimatorSetProxy runningAnimation2;
private int runningAnimationType; private int runningAnimationType;
private int keyboardHeight; private int keyboardHeight;
@ -134,6 +132,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
messsageEditText.setHint(LocaleController.getString("TypeMessage", R.string.TypeMessage)); messsageEditText.setHint(LocaleController.getString("TypeMessage", R.string.TypeMessage));
attachButton = (FrameLayout) containerView.findViewById(R.id.chat_attach_button); 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 = (ImageButton) containerView.findViewById(R.id.chat_send_button);
sendButton.setVisibility(View.INVISIBLE); sendButton.setVisibility(View.INVISIBLE);
@ -224,38 +225,37 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
recordingAudio = false; recordingAudio = false;
updateAudioRecordIntefrace(); 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(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
if (startedDraggingX != -1) { if (startedDraggingX != -1) {
float dist = (x - startedDraggingX); float dist = (x - startedDraggingX);
params.leftMargin = AndroidUtilities.dp(30) + (int) dist; params.leftMargin = AndroidUtilities.dp(30) + (int) dist;
slideText.setLayoutParams(params); slideText.setLayoutParams(params);
float alpha = 1.0f + dist / distCanMove; float alpha = 1.0f + dist / distCanMove;
if (alpha > 1) { if (alpha > 1) {
alpha = 1; alpha = 1;
} else if (alpha < 0) { } else if (alpha < 0) {
alpha = 0; alpha = 0;
}
slideText.setAlpha(alpha);
} }
if (x <= slideText.getX() + slideText.getWidth() + AndroidUtilities.dp(30)) { ViewProxy.setAlpha(slideText, alpha);
if (startedDraggingX == -1) { }
startedDraggingX = x; if (x <= ViewProxy.getX(slideText) + slideText.getWidth() + AndroidUtilities.dp(30)) {
distCanMove = (recordPanel.getMeasuredWidth() - slideText.getMeasuredWidth() - AndroidUtilities.dp(48)) / 2.0f; if (startedDraggingX == -1) {
if (distCanMove <= 0) { startedDraggingX = x;
distCanMove = AndroidUtilities.dp(80); distCanMove = (recordPanel.getMeasuredWidth() - slideText.getMeasuredWidth() - AndroidUtilities.dp(48)) / 2.0f;
} else if (distCanMove > AndroidUtilities.dp(80)) { if (distCanMove <= 0) {
distCanMove = AndroidUtilities.dp(80); distCanMove = AndroidUtilities.dp(80);
} } else if (distCanMove > AndroidUtilities.dp(80)) {
distCanMove = AndroidUtilities.dp(80);
} }
} }
if (params.leftMargin > AndroidUtilities.dp(30)) { }
params.leftMargin = AndroidUtilities.dp(30); if (params.leftMargin > AndroidUtilities.dp(30)) {
slideText.setLayoutParams(params); params.leftMargin = AndroidUtilities.dp(30);
slideText.setAlpha(1); slideText.setLayoutParams(params);
startedDraggingX = -1; ViewProxy.setAlpha(slideText, 1);
} startedDraggingX = -1;
} }
} }
view.onTouchEvent(motionEvent); view.onTouchEvent(motionEvent);
@ -349,46 +349,63 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
return src; return src;
} }
private void checkSendButton(boolean animated) { private void checkSendButton(final boolean animated) {
String message = getTrimmedString(messsageEditText.getText().toString()); String message = getTrimmedString(messsageEditText.getText().toString());
if (message.length() > 0) { if (message.length() > 0) {
if (audioSendButton.getVisibility() == View.VISIBLE) { if (audioSendButton.getVisibility() == View.VISIBLE) {
if (Build.VERSION.SDK_INT >= 11 && animated) { if (animated) {
if (runningAnimationType == 1) { if (runningAnimationType == 1) {
return; return;
} }
if (runningAnimation != null) { if (runningAnimation != null) {
((AnimatorSet) runningAnimation).cancel(); runningAnimation.cancel();
runningAnimation = null; runningAnimation = null;
} }
if (runningAnimation2 != null) {
runningAnimation2.cancel();
runningAnimation2 = null;
}
if (attachButton != null) {
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(2);
messsageEditText.setLayoutParams(layoutParams);
}
sendButton.setVisibility(View.VISIBLE); sendButton.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet(); runningAnimation = new AnimatorSetProxy();
runningAnimation = animatorSet;
runningAnimationType = 1; runningAnimationType = 1;
ArrayList<Animator> animators = new ArrayList<Animator>(); runningAnimation.playTogether(
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleX", 0.1f)); ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 0.1f),
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleY", 0.1f)); ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 0.1f),
animators.add(ObjectAnimator.ofFloat(audioSendButton, "alpha", 0.0f)); ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 0.0f),
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleX", 1.0f)); ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 1.0f),
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleY", 1.0f)); ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 1.0f),
animators.add(ObjectAnimator.ofFloat(sendButton, "alpha", 1.0f)); ObjectAnimatorProxy.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)));
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams(); runningAnimation.setDuration(150);
layoutParams.rightMargin = AndroidUtilities.dp(6); runningAnimation.addListener(new AnimatorListenerAdapterProxy() {
messsageEditText.setLayoutParams(layoutParams);
}
animatorSet.playTogether(animators);
animatorSet.setDuration(200);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Object animation) {
if (animation == runningAnimation) { if (runningAnimation.equals(animation)) {
sendButton.setVisibility(View.VISIBLE); sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE); audioSendButton.setVisibility(View.INVISIBLE);
runningAnimation = null; runningAnimation = null;
@ -396,16 +413,14 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
} }
} }
}); });
animatorSet.start(); runningAnimation.start();
} else { } else {
if (Build.VERSION.SDK_INT >= 11) { ViewProxy.setScaleX(audioSendButton, 0.1f);
audioSendButton.setScaleX(0.1f); ViewProxy.setScaleY(audioSendButton, 0.1f);
audioSendButton.setScaleY(0.1f); ViewProxy.setAlpha(audioSendButton, 0.0f);
audioSendButton.setAlpha(0.0f); ViewProxy.setScaleX(sendButton, 1.0f);
sendButton.setScaleX(1.0f); ViewProxy.setScaleY(sendButton, 1.0f);
sendButton.setScaleY(1.0f); ViewProxy.setAlpha(sendButton, 1.0f);
sendButton.setAlpha(1.0f);
}
sendButton.setVisibility(View.VISIBLE); sendButton.setVisibility(View.VISIBLE);
audioSendButton.setVisibility(View.INVISIBLE); audioSendButton.setVisibility(View.INVISIBLE);
if (attachButton != null) { if (attachButton != null) {
@ -414,43 +429,53 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
} }
} }
} else if (sendButton.getVisibility() == View.VISIBLE) { } else if (sendButton.getVisibility() == View.VISIBLE) {
if (Build.VERSION.SDK_INT >= 11 && animated) { if (animated) {
if (runningAnimationType == 2) { if (runningAnimationType == 2) {
return; return;
} }
if (runningAnimation != null) { if (runningAnimation != null) {
((AnimatorSet) runningAnimation).cancel(); runningAnimation.cancel();
runningAnimation = null; runningAnimation = null;
} }
if (runningAnimation2 != null) {
runningAnimation2.cancel();
runningAnimation2 = null;
}
if (attachButton != null) {
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(2);
messsageEditText.setLayoutParams(layoutParams);
}
audioSendButton.setVisibility(View.VISIBLE); audioSendButton.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet(); runningAnimation = new AnimatorSetProxy();
runningAnimation = animatorSet;
runningAnimationType = 2; runningAnimationType = 2;
ArrayList<Animator> animators = new ArrayList<Animator>(); runningAnimation.playTogether(
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleX", 0.1f)); ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 0.1f),
animators.add(ObjectAnimator.ofFloat(sendButton, "scaleY", 0.1f)); ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 0.1f),
animators.add(ObjectAnimator.ofFloat(sendButton, "alpha", 0.0f)); ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 0.0f),
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleX", 1.0f)); ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 1.0f),
animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleY", 1.0f)); ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 1.0f),
animators.add(ObjectAnimator.ofFloat(audioSendButton, "alpha", 1.0f)); ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 1.0f)
if (attachButton != null) { );
animators.add(ObjectAnimator.ofFloat(attachButton, "alpha", 1.0f));
animators.add(ObjectAnimator.ofFloat(attachButton, "translationX", 0.0f));
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams(); runningAnimation.setDuration(150);
layoutParams.rightMargin = AndroidUtilities.dp(54); runningAnimation.addListener(new AnimatorListenerAdapterProxy() {
messsageEditText.setLayoutParams(layoutParams);
}
animatorSet.playTogether(animators);
animatorSet.setDuration(200);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Object animation) {
if (animation == runningAnimation) { if (runningAnimation.equals(animation)) {
sendButton.setVisibility(View.INVISIBLE); sendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.VISIBLE); audioSendButton.setVisibility(View.VISIBLE);
runningAnimation = null; runningAnimation = null;
@ -458,16 +483,14 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
} }
} }
}); });
animatorSet.start(); runningAnimation.start();
} else { } else {
if (Build.VERSION.SDK_INT >= 11) { ViewProxy.setScaleX(sendButton, 0.1f);
sendButton.setScaleX(0.1f); ViewProxy.setScaleY(sendButton, 0.1f);
sendButton.setScaleY(0.1f); ViewProxy.setAlpha(sendButton, 0.0f);
sendButton.setAlpha(0.0f); ViewProxy.setScaleX(audioSendButton, 1.0f);
audioSendButton.setScaleX(1.0f); ViewProxy.setScaleY(audioSendButton, 1.0f);
audioSendButton.setScaleY(1.0f); ViewProxy.setAlpha(audioSendButton, 1.0f);
audioSendButton.setAlpha(1.0f);
}
sendButton.setVisibility(View.INVISIBLE); sendButton.setVisibility(View.INVISIBLE);
audioSendButton.setVisibility(View.VISIBLE); audioSendButton.setVisibility(View.VISIBLE);
if (attachButton != null) { if (attachButton != null) {
@ -493,31 +516,21 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
recordPanel.setVisibility(View.VISIBLE); recordPanel.setVisibility(View.VISIBLE);
recordTimeText.setText("00:00"); recordTimeText.setText("00:00");
lastTimeString = null; 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);
recordPanel.setX(AndroidUtilities.displaySize.x);
recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
public void onAnimationEnd(Animator animator) { params.leftMargin = AndroidUtilities.dp(30);
recordPanel.setX(0); slideText.setLayoutParams(params);
} ViewProxy.setAlpha(slideText, 1);
recordPanel.setX(AndroidUtilities.displaySize.x);
@Override ObjectAnimatorProxy animatorProxy = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", 0).setDuration(300);
public void onAnimationCancel(Animator animator) { animatorProxy.addListener(new AnimatorListenerAdapterProxy() {
} @Override
public void onAnimationEnd(Object animator) {
@Override ViewProxy.setX(recordPanel, 0);
public void onAnimationRepeat(Animator animator) { }
} });
}).setDuration(300).translationX(0).start(); animatorProxy.setInterpolator(new AccelerateDecelerateInterpolator());
} animatorProxy.start();
} else { } else {
if (mWakeLock != null) { if (mWakeLock != null) {
try { try {
@ -528,33 +541,20 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
} }
} }
AndroidUtilities.unlockOrientation(parentActivity); 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 @Override
public void onAnimationEnd(Animator animator) { public void onAnimationEnd(Object animator) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
params.leftMargin = AndroidUtilities.dp(30); params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params); slideText.setLayoutParams(params);
slideText.setAlpha(1); ViewProxy.setAlpha(slideText, 1);
recordPanel.setVisibility(View.GONE); recordPanel.setVisibility(View.GONE);
} }
});
@Override animatorProxy.setInterpolator(new AccelerateDecelerateInterpolator());
public void onAnimationCancel(Animator animator) { animatorProxy.start();
}
@Override
public void onAnimationRepeat(Animator animator) {
}
}).setDuration(300).translationX(AndroidUtilities.displaySize.x).start();
} else {
recordPanel.setVisibility(View.GONE);
}
} }
} }

View File

@ -10,9 +10,13 @@ package org.telegram.ui.Views;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.view.View; import android.view.View;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
@ -28,6 +32,14 @@ public class ClippingImageView extends View {
private Bitmap bmp; private Bitmap bmp;
private onDrawListener drawListener; 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 static interface onDrawListener {
public abstract void onDraw(); public abstract void onDraw();
} }
@ -59,6 +71,10 @@ public class ClippingImageView extends View {
return clipTop; return clipTop;
} }
public int getRadius() {
return radius;
}
public void onDraw(Canvas canvas) { public void onDraw(Canvas canvas) {
if (getVisibility() == GONE || getVisibility() == INVISIBLE) { if (getVisibility() == GONE || getVisibility() == INVISIBLE) {
return; return;
@ -69,12 +85,20 @@ public class ClippingImageView extends View {
drawListener.onDraw(); drawListener.onDraw();
} }
canvas.save(); canvas.save();
canvas.clipRect(clipLeft / scaleY, clipTop / scaleY, getWidth() - clipRight / scaleY, getHeight() - clipBottom / scaleY); if (needRadius) {
drawRect.set(0, 0, getWidth(), getHeight()); roundRect.set(0, 0, getWidth(), getHeight());
try { shaderMatrix.reset();
canvas.drawBitmap(this.bmp, null, drawRect, this.paint); shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL);
} catch (Exception e) { bitmapShader.setLocalMatrix(shaderMatrix);
FileLog.e("tmessages", e); 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(bmp, null, drawRect, paint);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} }
canvas.restore(); canvas.restore();
} }
@ -114,10 +138,27 @@ public class ClippingImageView extends View {
public void setImageBitmap(Bitmap bitmap) { public void setImageBitmap(Bitmap bitmap) {
bmp = 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(); invalidate();
} }
public void setOnDrawListener(onDrawListener listener) { public void setOnDrawListener(onDrawListener listener) {
drawListener = listener; drawListener = listener;
} }
public void setNeedRadius(boolean value) {
needRadius = value;
}
public void setRadius(int value) {
radius = value;
}
} }

View File

@ -1,85 +0,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.Views;
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.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
public class SettingsSectionLayout extends LinearLayout {
private TextView textView;
private void init() {
setOrientation(LinearLayout.VERTICAL);
textView = new TextView(getContext());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
textView.setTextColor(0xff3b84c0);
addView(textView);
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;
}
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));
}
public void setText(String text) {
textView.setText(text);
}
}

View File

@ -10,20 +10,19 @@ package org.telegram.ui.Views;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Layout; import android.text.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
public class TimerButton extends View { public class TimerDrawable extends Drawable {
private static Drawable emptyTimerDrawable; private static Drawable emptyTimerDrawable;
private static Drawable timerDrawable; private static Drawable timerDrawable;
@ -33,32 +32,15 @@ public class TimerButton extends View {
private int timeHeight = 0; private int timeHeight = 0;
private int time = 0; private int time = 0;
private void init() { public TimerDrawable(Context context) {
if (emptyTimerDrawable == null) { if (emptyTimerDrawable == null) {
emptyTimerDrawable = getResources().getDrawable(R.drawable.header_timer); emptyTimerDrawable = context.getResources().getDrawable(R.drawable.header_timer);
timerDrawable = getResources().getDrawable(R.drawable.header_timer2); timerDrawable = context.getResources().getDrawable(R.drawable.header_timer2);
timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
timePaint.setTextSize(AndroidUtilities.dp(10)); timePaint.setTextSize(AndroidUtilities.dp(10));
timePaint.setColor(0xffd7e8f7); timePaint.setColor(0xffd7e8f7);
timePaint.setTypeface(Typeface.DEFAULT_BOLD); 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) { public void setTime(int value) {
@ -103,13 +85,13 @@ public class TimerButton extends View {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
invalidate(); invalidateSelf();
} }
@Override @Override
protected void onDraw(Canvas canvas) { public void draw(Canvas canvas) {
int width = getMeasuredWidth(); int width = canvas.getWidth();
int height = getMeasuredHeight(); int height = canvas.getHeight();
Drawable drawable = null; Drawable drawable = null;
if (time == 0) { if (time == 0) {
drawable = timerDrawable; drawable = timerDrawable;
@ -127,4 +109,29 @@ public class TimerButton extends View {
timeLayout.draw(canvas); 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;
}
} }

View File

@ -155,7 +155,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
}); });
ActionBarMenu menu = actionBar.createMenu(); 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); fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(getParentActivity());

View File

@ -1,7 +0,0 @@
<?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>

View File

@ -1,7 +0,0 @@
<?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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

BIN
TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Some files were not shown because too many files have changed in this diff Show More