1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-12 07:29:37 +01:00

More Android L design

This commit is contained in:
DrKLO 2014-11-18 01:04:31 +03:00
parent f7b14c1e23
commit ce33df07ad
45 changed files with 381 additions and 231 deletions

View File

@ -71,24 +71,22 @@ public class AndroidUtilities {
if (manager != null && manager.getDefaultDisplay() != null) {
int rotation = manager.getDefaultDisplay().getRotation();
int orientation = activity.getResources().getConfiguration().orientation;
int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
if (Build.VERSION.SDK_INT < 9) {
SCREEN_ORIENTATION_REVERSE_LANDSCAPE = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
SCREEN_ORIENTATION_REVERSE_PORTRAIT = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
if (rotation == Surface.ROTATION_270) {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else {
if (Build.VERSION.SDK_INT >= 9) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
} else {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
}
} else if (rotation == Surface.ROTATION_90) {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
if (Build.VERSION.SDK_INT >= 9) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
} else {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_PORTRAIT);
} else {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@ -100,17 +98,9 @@ public class AndroidUtilities {
}
} else {
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
if (Build.VERSION.SDK_INT >= 9) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
} else {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
} else {
if (Build.VERSION.SDK_INT >= 9) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
} else {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_PORTRAIT);
}
}
}
@ -472,7 +462,7 @@ public class AndroidUtilities {
return size;
}
public static void setListViewEdgeEffectColor(ListView listView, int color) {
public static void setListViewEdgeEffectColor(AbsListView listView, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = AbsListView.class.getDeclaredField("mEdgeGlowTop");

View File

@ -41,6 +41,7 @@ import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;
public class ContactsController {
private Account currentAccount;
private boolean loadingContacts = false;
private static final Object loadContactsSync = new Object();
@ -108,6 +109,13 @@ public class ContactsController {
return localInstance;
}
public ContactsController() {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
if (preferences.getBoolean("needGetStatuses", false)) {
reloadContactsStatuses();
}
}
public void cleanup() {
contactsBook.clear();
contactsBookSPhones.clear();
@ -1577,6 +1585,42 @@ public class ContactsController {
}, true, RPCRequest.RPCRequestClassGeneric);
}
public void reloadContactsStatuses() {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
final SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("needGetStatuses", true).commit();
TLRPC.TL_contacts_getStatuses req = new TLRPC.TL_contacts_getStatuses();
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(final TLObject response, TLRPC.TL_error error) {
if (error == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
editor.remove("needGetStatuses").commit();
TLRPC.Vector vector = (TLRPC.Vector) response;
if (!vector.objects.isEmpty()) {
ArrayList<TLRPC.User> dbUsersStatus = new ArrayList<TLRPC.User>();
for (Object object : vector.objects) {
TLRPC.User toDbUser = new TLRPC.User();
TLRPC.TL_contactStatus status = (TLRPC.TL_contactStatus) object;
TLRPC.User user = MessagesController.getInstance().getUser(status.user_id);
if (user != null) {
user.status = status.status;
}
toDbUser.status = status.status;
dbUsersStatus.add(toDbUser);
}
MessagesStorage.getInstance().updateUsers(dbUsersStatus, true, true, true);
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_STATUS);
}
});
}
}
});
}
public void loadPrivacySettings() {
if (loadingDeleteInfo == 0) {
loadingDeleteInfo = 1;
@ -1650,6 +1694,7 @@ public class ContactsController {
public void setPrivacyRules(ArrayList<TLRPC.PrivacyRule> rules) {
privacyRules = rules;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.privacyRulesUpdated);
reloadContactsStatuses();
}
public static String formatName(String firstName, String lastName) {

View File

@ -1117,9 +1117,9 @@ public class ImageLoader {
return b;
}
private static TLRPC.PhotoSize scaleAndSaveImageInternal(Bitmap bitmap, int w, int h, float photoW, float photoH, float scaleFactor, int quality, boolean cache) throws Exception {
private static TLRPC.PhotoSize scaleAndSaveImageInternal(Bitmap bitmap, int w, int h, float photoW, float photoH, float scaleFactor, int quality, boolean cache, boolean scaleAnyway) throws Exception {
Bitmap scaledBitmap = null;
if (scaleFactor > 1) {
if (scaleFactor > 1 || scaleAnyway) {
scaledBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
} else {
scaledBitmap = bitmap;
@ -1171,6 +1171,10 @@ public class ImageLoader {
}
public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache) {
return scaleAndSaveImage(bitmap, maxWidth, maxHeight, quality, cache, 0, 0);
}
public static TLRPC.PhotoSize scaleAndSaveImage(Bitmap bitmap, float maxWidth, float maxHeight, int quality, boolean cache, int minWidth, int minHeight) {
if (bitmap == null) {
return null;
}
@ -1179,7 +1183,12 @@ public class ImageLoader {
if (photoW == 0 || photoH == 0) {
return null;
}
boolean scaleAnyway = false;
float scaleFactor = Math.max(photoW / maxWidth, photoH / maxHeight);
if (scaleFactor < 1 && minWidth != 0 && minHeight != 0) {
scaleFactor = Math.max(photoW / minWidth, photoH / minHeight);
scaleAnyway = true;
}
int w = (int)(photoW / scaleFactor);
int h = (int)(photoH / scaleFactor);
if (h == 0 || w == 0) {
@ -1187,13 +1196,13 @@ public class ImageLoader {
}
try {
return scaleAndSaveImageInternal(bitmap, w, h, photoW, photoH, scaleFactor, quality, cache);
return scaleAndSaveImageInternal(bitmap, w, h, photoW, photoH, scaleFactor, quality, cache, scaleAnyway);
} catch (Throwable e) {
FileLog.e("tmessages", e);
ImageLoader.getInstance().clearMemory();
System.gc();
try {
return scaleAndSaveImageInternal(bitmap, w, h, photoW, photoH, scaleFactor, quality, cache);
return scaleAndSaveImageInternal(bitmap, w, h, photoW, photoH, scaleFactor, quality, cache, scaleAnyway);
} catch (Throwable e2) {
FileLog.e("tmessages", e2);
return null;

View File

@ -1375,10 +1375,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
@Override
public void run() {
int lower_id = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (!isCache) {
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
}
if (lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 2 || load_type == 3)) {
if (high_id != 1 && lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 2 || load_type == 3)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {

View File

@ -272,20 +272,20 @@ public class TLRPC {
}
public static class TL_contactStatus extends TLObject {
public static int constructor = 0xaa77b873;
public static int constructor = 0xd3680c61;
public int user_id;
public int expires;
public UserStatus status;
public void readParams(AbsSerializedData stream) {
user_id = stream.readInt32();
expires = stream.readInt32();
status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(user_id);
stream.writeInt32(expires);
status.serializeToStream(stream);
}
}
@ -7389,6 +7389,18 @@ public class TLRPC {
public static class TL_contacts_getStatuses extends TLObject {
public static int constructor = 0xc4a353ee;
public ArrayList<TL_contactStatus> id = new ArrayList<TL_contactStatus>();
public Class responseClass () {
return Vector.class;
}
public void parseVector(Vector vector, AbsSerializedData data) {
int size = data.readInt32();
for (int a = 0; a < size; a++) {
vector.objects.add(TLClassStore.Instance().TLdeserialize(data, data.readInt32()));
}
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);

View File

@ -114,7 +114,7 @@ public class Utilities {
private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length);
public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) {
aesIgeEncryption(buffer, key, changeIv ? iv : iv.clone(), encrypt, offset, length);
aesIgeEncryption(buffer, key, changeIv ? iv : (byte [])iv.clone(), encrypt, offset, length);
}
public static Integer parseInt(String value) {
@ -640,7 +640,7 @@ public class Utilities {
builder.append(" ");
}
query.trim();
builder.append(Html.fromHtml("<font color=\"#548ab6\">" + query + "</font>"));
builder.append(Html.fromHtml("<font color=\"#4d83b3\">" + query + "</font>"));
lastIndex = end;
}

View File

@ -633,6 +633,10 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.start();
}
} else {
if (backgroundView != null) {
ViewProxy.setAlpha(backgroundView, 1.0f);
backgroundView.setVisibility(VISIBLE);
}
fragment.onOpenAnimationEnd();
}
return true;
@ -789,6 +793,10 @@ public class ActionBarLayout extends FrameLayout {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(previousFragment.actionBar);
}
containerView.addView(previousFragment.actionBar);
}
containerView.addView(fragmentView);

View File

@ -264,7 +264,7 @@ public class ActionBarMenuItem extends ImageView {
private int getBottomOffsetY() {
getLocationOnScreen(location);
int diff = location[1] - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + getMeasuredHeight() - menuHeight;
int diff = location[1] - AndroidUtilities.statusBarHeight + getMeasuredHeight() - menuHeight;
int y = AndroidUtilities.dp(8) - menuHeight;
if (diff < 0) {
y -= diff;

View File

@ -218,7 +218,6 @@ public class DrawerLayoutContainer extends FrameLayout {
}
private void onDrawerAnimationEnd(boolean opened) {
AndroidUtilities.unlockOrientation((Activity) getContext());
startedTracking = false;
currentAnimation = null;
drawerOpened = opened;
@ -257,7 +256,6 @@ public class DrawerLayoutContainer extends FrameLayout {
startedTrackingX = (int) ev.getX();
}
beginTrackingSent = false;
AndroidUtilities.lockOrientation((Activity)getContext());
}
public boolean isDrawerOpened() {

View File

@ -234,7 +234,7 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
}
} else if (i > searchResult.size() && user.username != null) {
try {
username = Html.fromHtml(String.format("<font color=\"#548ab6\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
username = Html.fromHtml(String.format("<font color=\"#4d83b3\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
} catch (Exception e) {
username = user.username;
FileLog.e("tmessages", e);

View File

@ -48,13 +48,15 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
private long reqId = 0;
private int lastReqId;
private MessagesActivitySearchAdapterDelegate delegate;
private boolean needMessagesSearch;
public static interface MessagesActivitySearchAdapterDelegate {
public abstract void searchStateChanged(boolean searching);
}
public DialogsSearchAdapter(Context context) {
public DialogsSearchAdapter(Context context, boolean messagesSearch) {
mContext = context;
needMessagesSearch = messagesSearch;
}
public void setDelegate(MessagesActivitySearchAdapterDelegate delegate) {
@ -62,6 +64,9 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
}
private void searchMessagesInternal(final String query) {
if (!needMessagesSearch) {
return;
}
if (reqId != 0) {
ConnectionsManager.getInstance().cancelRpc(reqId, true);
reqId = 0;
@ -412,7 +417,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
}
} else if (i > searchResult.size() && user != null && user.username != null) {
try {
username = Html.fromHtml(String.format("<font color=\"#548ab6\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
username = Html.fromHtml(String.format("<font color=\"#4d83b3\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
} catch (Exception e) {
username = user.username;
FileLog.e("tmessages", e);

View File

@ -121,4 +121,9 @@ public class ObjectAnimatorProxy {
}
return this;
}
@Override
public boolean equals(Object o) {
return objectAnimator == o;
}
}

View File

@ -120,7 +120,7 @@ public class DialogCell extends BaseCell {
nameUnknownPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
nameUnknownPaint.setTextSize(AndroidUtilities.dp(17));
nameUnknownPaint.setColor(0xff548ab6);
nameUnknownPaint.setColor(0xff4d83b3);
nameUnknownPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
@ -132,7 +132,7 @@ public class DialogCell extends BaseCell {
messagePrintingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
messagePrintingPaint.setTextSize(AndroidUtilities.dp(16));
messagePrintingPaint.setColor(0xff548ab6);
messagePrintingPaint.setColor(0xff4d83b3);
timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
timePaint.setTextSize(AndroidUtilities.dp(13));
@ -325,10 +325,10 @@ public class DialogCell extends BaseCell {
checkMessage = false;
if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
currentMessagePaint = messagePrintingPaint;
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#548ab6>%s:</font> <font color=#548ab6>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#4d83b3>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
} else {
if (message.messageOwner.message != null) {
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#548ab6>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
}
}
} else {

View File

@ -28,6 +28,7 @@ public class EmptyCell extends FrameLayout {
public void setHeight(int height) {
cellHeight = height;
requestLayout();
}
@Override

View File

@ -58,8 +58,8 @@ public class TextCell extends FrameLayout {
layoutParams = (LayoutParams) valueTextView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.MATCH_PARENT;
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 24 : 0);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 24);
layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT;
valueTextView.setLayoutParams(layoutParams);
@ -80,8 +80,8 @@ public class TextCell extends FrameLayout {
layoutParams = (LayoutParams) valueImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 24 : 0);
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 24);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL;
valueImageView.setLayoutParams(layoutParams);
}

View File

@ -453,7 +453,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
lastStatus = null;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(final int id) {
@ -699,16 +698,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
presentFragment(new ProfileActivity(args));
} else if (currentChat != null) {
if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) {
return;
}
int count = currentChat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) {
return;
}
Bundle args = new Bundle();
args.putInt("chat_id", currentChat.id);
ProfileActivity fragment = new ProfileActivity(args);
@ -718,6 +707,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
if (currentChat != null) {
int count = currentChat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden || info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) {
avatarContainer.setEnabled(false);
}
}
avatarImageView = new BackupImageView(getParentActivity());
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(21));
avatarImageView.processDetach = false;
@ -768,10 +767,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateSubtitle();
if (currentEncryptedChat != null) {
nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
} else if (currentChat != null && currentChat.id < 0) {
nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.broadcast2, 0, 0, 0);
nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_header, 0, 0, 0);
nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
}
@ -2471,6 +2467,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
if (chatAdapter != null) {
chatAdapter.notifyDataSetChanged();
}
checkActionBarMenu();
NotificationsController.getInstance().setOpennedDialogId(dialog_id);
@ -2543,7 +2543,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onPause() {
super.onPause();
actionBar.hideActionMode();
chatActivityEnterView.hideEmojiPopup();
paused = true;
NotificationsController.getInstance().setOpennedDialogId(0);
@ -2660,6 +2659,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
forwaringMessage = null;
selectedMessagesCanCopyIds.clear();
selectedMessagesIds.clear();
actionBar.hideActionMode();
if (single || type < 2 || type == 6) {
if (type >= 0) {
@ -2928,6 +2928,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
selectedMessagesCanCopyIds.clear();
selectedMessagesIds.clear();
actionBar.hideActionMode();
}
}

View File

@ -51,6 +51,8 @@ import java.util.ArrayList;
import java.util.concurrent.Semaphore;
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
private ListAdapter listAdapter;
private ListView listView;
private EditText nameTextView;
private TLRPC.FileLocation avatar;
@ -126,6 +128,14 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
avatarUpdater.clear();
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) {
@ -297,7 +307,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
listView.setAdapter(new ListAdapter(getParentActivity()));
listView.setAdapter(listAdapter = new ListAdapter(getParentActivity()));
linearLayout.addView(listView);
layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;

View File

@ -49,7 +49,6 @@ public class IdenticonActivity extends BaseFragment {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
actionBar.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override

View File

@ -8,8 +8,12 @@
package org.telegram.ui;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
@ -105,59 +109,30 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
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 (getParentActivity() == null) {
return;
}
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() {
if (currentType != 0) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
boolean showed = preferences.getBoolean("privacyAlertShowed", false);
if (!showed) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("CustomHelp", R.string.CustomHelp));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@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();
}
public void onClick(DialogInterface dialogInterface, int i) {
applyCurrentPrivacySettings();
preferences.edit().putBoolean("privacyAlertShowed", true).commit();
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
return;
}
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
}
applyCurrentPrivacySettings();
}
}
});
@ -271,6 +246,73 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
}
}
private void applyCurrentPrivacySettings() {
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());
}
final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
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 (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);
}
private void showErrorAlert() {
if (getParentActivity() == null) {
return;

View File

@ -735,6 +735,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else {
actionBarLayout.presentFragment(fragment, true);
if (sendingText != null) {
fragment.processSendingText(sendingText);
}
@ -1156,10 +1157,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
}
if (actionBarLayout.fragmentsStack.size() > 1) {
actionBarLayout.presentFragment(fragment, actionBarLayout.fragmentsStack.size() > 1, forceWithoutAnimation, false);
return false;
}
actionBarLayout.presentFragment(fragment, actionBarLayout.fragmentsStack.size() > 1, forceWithoutAnimation, false);
return false;
}
} else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE);

View File

@ -994,7 +994,7 @@ public class LoginActivity extends BaseFragment {
codeField.setHintTextColor(0xff979797);
codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
codeField.setInputType(InputType.TYPE_CLASS_NUMBER);
codeField.setInputType(InputType.TYPE_CLASS_PHONE);
codeField.setMaxLines(1);
codeField.setPadding(0, 0, 0, 0);
addView(codeField);
@ -1037,7 +1037,7 @@ public class LoginActivity extends BaseFragment {
problemText.setVisibility(time < 1000 ? VISIBLE : GONE);
problemText.setGravity(Gravity.LEFT);
problemText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
problemText.setTextColor(0xff548ab6);
problemText.setTextColor(0xff4d83b3);
problemText.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
problemText.setPadding(0, AndroidUtilities.dp(2), 0, AndroidUtilities.dp(12));
addView(problemText);
@ -1078,7 +1078,7 @@ public class LoginActivity extends BaseFragment {
TextView wrongNumber = new TextView(context);
wrongNumber.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL);
wrongNumber.setTextColor(0xff548ab6);
wrongNumber.setTextColor(0xff4d83b3);
wrongNumber.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
wrongNumber.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0);
@ -1487,7 +1487,7 @@ public class LoginActivity extends BaseFragment {
TextView wrongNumber = new TextView(context);
wrongNumber.setText(LocaleController.getString("CancelRegistration", R.string.CancelRegistration));
wrongNumber.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL);
wrongNumber.setTextColor(0xff548ab6);
wrongNumber.setTextColor(0xff4d83b3);
wrongNumber.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
wrongNumber.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0);

View File

@ -223,7 +223,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity());
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), !onlySelect);
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
@Override
public void searchStateChanged(boolean search) {

View File

@ -10,6 +10,7 @@ package org.telegram.ui;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@ -628,6 +629,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (f != null && f.exists()) {
MediaController.saveFile(f.toString(), parentActivity, currentFileNames[0].endsWith("mp4") ? 1 : 0, null);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(R.string.OK, null);
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
builder.show().setCanceledOnTouchOutside(true);
}
} else if (id == gallery_menu_showall) {
if (opennedFromMedia) {
@ -745,6 +752,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
parentActivity.startActivity(intent);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(R.string.OK, null);
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
builder.show().setCanceledOnTouchOutside(true);
}
} catch (Exception e) {
FileLog.e("tmessages", e);

View File

@ -172,7 +172,6 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
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),
@ -181,13 +180,13 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
@Override
public void onClick(DialogInterface dialog, int which) {
int value = 0;
if (which == 1) {
if (which == 0) {
value = 30;
} else if (which == 2) {
} else if (which == 1) {
value = 60;
} else if (which == 3) {
} else if (which == 2) {
value = 182;
} else if (which == 4) {
} else if (which == 3) {
value = 365;
}
final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
@ -366,9 +365,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
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) {
if (ttl <= 182) {
value = LocaleController.formatPluralString("Months", ttl / 30);
} else if (ttl == 365) {
value = LocaleController.formatPluralString("Years", ttl / 365);

View File

@ -222,7 +222,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 ? user_id : chat_id));
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 ? user_id : chat_id));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
@ -409,8 +408,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
onlineTextView.setLayoutParams(layoutParams);
listView = new ListView(getParentActivity());
listView.setDrawingCacheEnabled(false);
listView.setDrawingCacheBackgroundColor(0);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
@ -554,7 +551,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
frameLayout.addView(actionBar);
if (user_id != 0 || chat_id >= 0) {
if (user_id != 0 || chat_id >= 0 && !currentChat.left) {
writeButton = new ImageView(getParentActivity());
if (user_id != 0) {
writeButton.setImageResource(R.drawable.floating_user_states);
@ -602,7 +599,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
avatarUpdater.openCamera();
} else if (i == 1) {
avatarUpdater.openGallery();
} else if (i == 3) {
} else if (i == 2) {
MessagesController.getInstance().changeChatAvatar(chat_id, null);
}
}
@ -890,7 +887,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { }
@Override
public void willHidePhotoViewer() { }
public void willHidePhotoViewer() {
avatarImage.imageReceiver.setVisible(true, true);
}
@Override
public boolean isPhotoChecked(int index) { return false; }
@ -1065,6 +1064,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
photoBig = chat.photo.photo_big;
}
avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
}
}

View File

@ -18,7 +18,6 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.Spannable;
@ -211,11 +210,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
usernameRow = rowCount++;
settingsSectionRow = rowCount++;
settingsSectionRow2 = rowCount++;
enableAnimationsRow = rowCount++;
notificationRow = rowCount++;
privacyRow = rowCount++;
backgroundRow = rowCount++;
languageRow = rowCount++;
enableAnimationsRow = rowCount++;
mediaDownloadSection = rowCount++;
mediaDownloadSection2 = rowCount++;
mobileDownloadRow = rowCount++;
@ -264,7 +263,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5));
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackOverlay(R.layout.updating_state_layout);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
@ -637,7 +635,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
avatarUpdater.openCamera();
} else if (i == 1) {
avatarUpdater.openGallery();
} else if (i == 3) {
} else if (i == 2) {
MessagesController.getInstance().deleteUserPhoto(null);
}
}
@ -716,7 +714,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { }
@Override
public void willHidePhotoViewer() { }
public void willHidePhotoViewer() {
avatarImage.imageReceiver.setVisible(true, true);
}
@Override
public boolean isPhotoChecked(int index) { return false; }
@ -1034,7 +1034,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
textCell.setTextAndValue(LocaleController.getString("TextSize", R.string.TextSize), String.format("%d", size), true);
} else if (i == languageRow) {
textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), false);
textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), true);
} else if (i == contactsSortRow) {
String value;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
@ -1074,7 +1074,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
if (i == enableAnimationsRow) {
textCell.setTextAndCheck(LocaleController.getString("EnableAnimations", R.string.EnableAnimations), preferences.getBoolean("view_animations", true), true);
textCell.setTextAndCheck(LocaleController.getString("EnableAnimations", R.string.EnableAnimations), preferences.getBoolean("view_animations", true), false);
} else if (i == sendByEnterRow) {
textCell.setTextAndCheck(LocaleController.getString("SendByEnter", R.string.SendByEnter), preferences.getBoolean("send_by_enter", false), false);
} else if (i == saveToGalleryRow) {

View File

@ -21,8 +21,11 @@ import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ApplicationLoader;
import java.util.Locale;
public class AvatarDrawable extends Drawable {
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
@ -58,47 +61,69 @@ public class AvatarDrawable extends Drawable {
}
public AvatarDrawable(TLRPC.User user) {
this();
this(user, false);
}
public AvatarDrawable(TLRPC.Chat chat) {
this(chat, false);
}
public AvatarDrawable(TLRPC.User user, boolean profile) {
isProfile = profile;
if (user != null) {
setInfo(user.id, user.first_name, user.last_name, false);
}
}
public AvatarDrawable(TLRPC.Chat chat) {
this();
public AvatarDrawable(TLRPC.Chat chat, boolean profile) {
isProfile = profile;
if (chat != null) {
setInfo(chat.id, chat.title, null, chat.id < 0);
}
}
public AvatarDrawable(TLRPC.User user, boolean profile) {
this(user);
isProfile = profile;
}
public AvatarDrawable(TLRPC.Chat chat, boolean profile) {
this(chat);
isProfile = profile;
public static int getColorIndex(int id) {
try {
String str;
if (id >= 0) {
str = String.format(Locale.US, "%d%d", id, UserConfig.getClientUserId());
} else {
str = String.format(Locale.US, "%d", id);
}
if (str.length() > 15) {
str = str.substring(0, 15);
}
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] digest = md.digest(str.getBytes());
int b = digest[Math.abs(id % 16)];
if (b < 0) {
b += 256;
}
return Math.abs(b) % arrColors.length;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return id % arrColors.length;
}
public static int getColorForId(int id) {
return arrColors[Math.abs(id) % arrColors.length];
return arrColors[getColorIndex(id)];
}
public static int getButtonColorForId(int id) {
return arrColorsButtons[Math.abs(id) % arrColorsButtons.length];
return arrColorsButtons[getColorIndex(id)];
}
public static int getProfileColorForId(int id) {
return arrColorsProfiles[Math.abs(id) % arrColorsProfiles.length];
return arrColorsProfiles[getColorIndex(id)];
}
public static int getProfileTextColorForId(int id) {
return arrColorsProfilesText[Math.abs(id) % arrColorsProfilesText.length];
return arrColorsProfilesText[getColorIndex(id)];
}
public static int getProfileBackColorForId(int id) {
return arrColorsProfilesBack[Math.abs(id) % arrColorsProfilesBack.length];
return arrColorsProfilesBack[getColorIndex(id)];
}
public void setInfo(TLRPC.User user) {
@ -119,9 +144,9 @@ public class AvatarDrawable extends Drawable {
public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) {
if (isProfile) {
color = arrColorsProfiles[Math.abs(id) % arrColorsProfiles.length];
color = arrColorsProfiles[getColorIndex(id)];
} else {
color = arrColors[Math.abs(id) % arrColors.length];
color = arrColors[getColorIndex(id)];
}
drawBrodcast = isBroadcast;

View File

@ -120,7 +120,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
return;
}
smallPhoto = ImageLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false);
bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false);
bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false, 320, 320);
if (bigPhoto != null && smallPhoto != null) {
if (returnOnly) {
if (delegate != null) {

View File

@ -70,7 +70,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
private FrameLayout attachButton;
private AnimatorSetProxy runningAnimation;
private AnimatorSetProxy runningAnimation2;
private ObjectAnimatorProxy runningAnimationAudio;
private int runningAnimationType;
private int audioInterfaceState;
private int keyboardHeight;
private int keyboardHeightLand;
@ -502,6 +504,10 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
private void updateAudioRecordIntefrace() {
if (recordingAudio) {
if (audioInterfaceState == 1) {
return;
}
audioInterfaceState = 1;
try {
if (mWakeLock == null) {
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
@ -521,16 +527,21 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params);
ViewProxy.setAlpha(slideText, 1);
recordPanel.setX(AndroidUtilities.displaySize.x);
ObjectAnimatorProxy animatorProxy = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", 0).setDuration(300);
animatorProxy.addListener(new AnimatorListenerAdapterProxy() {
ViewProxy.setX(recordPanel, AndroidUtilities.displaySize.x);
if (runningAnimationAudio != null) {
runningAnimationAudio.cancel();
}
runningAnimationAudio = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", 0).setDuration(300);
runningAnimationAudio.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animator) {
ViewProxy.setX(recordPanel, 0);
if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) {
ViewProxy.setX(recordPanel, 0);
}
}
});
animatorProxy.setInterpolator(new AccelerateDecelerateInterpolator());
animatorProxy.start();
runningAnimationAudio.setInterpolator(new AccelerateDecelerateInterpolator());
runningAnimationAudio.start();
} else {
if (mWakeLock != null) {
try {
@ -541,20 +552,29 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
}
}
AndroidUtilities.unlockOrientation(parentActivity);
if (audioInterfaceState == 0) {
return;
}
audioInterfaceState = 0;
ObjectAnimatorProxy animatorProxy = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", AndroidUtilities.displaySize.x).setDuration(300);
animatorProxy.addListener(new AnimatorListenerAdapterProxy() {
if (runningAnimationAudio != null) {
runningAnimationAudio.cancel();
}
runningAnimationAudio = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", AndroidUtilities.displaySize.x).setDuration(300);
runningAnimationAudio.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animator) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params);
ViewProxy.setAlpha(slideText, 1);
recordPanel.setVisibility(View.GONE);
if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
params.leftMargin = AndroidUtilities.dp(30);
slideText.setLayoutParams(params);
ViewProxy.setAlpha(slideText, 1);
recordPanel.setVisibility(View.GONE);
}
}
});
animatorProxy.setInterpolator(new AccelerateDecelerateInterpolator());
animatorProxy.start();
runningAnimationAudio.setInterpolator(new AccelerateDecelerateInterpolator());
runningAnimationAudio.start();
}
}

View File

@ -10,7 +10,6 @@ package org.telegram.ui.Views;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.drawable.GradientDrawable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
@ -114,10 +113,11 @@ public class EmojiView extends LinearLayout {
EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
gridView.setAdapter(localEmojiGridAdapter);
AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999);
adapters.add(localEmojiGridAdapter);
}
setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 }));
setBackgroundColor(0xff222222);
pager = new ViewPager(getContext());
pager.setAdapter(new EmojiPagesAdapter());
PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
@ -258,33 +258,30 @@ public class EmojiView extends LinearLayout {
private class EmojiPagesAdapter extends PagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
private EmojiPagesAdapter() {
}
public void destroyItem(ViewGroup paramViewGroup, int paramInt, Object paramObject) {
View localObject;
if (paramInt == 0) {
localObject = EmojiView.this.recentsWrap;
localObject = recentsWrap;
} else {
localObject = EmojiView.this.views.get(paramInt);
localObject = views.get(paramInt);
}
paramViewGroup.removeView(localObject);
}
public int getCount() {
return EmojiView.this.views.size();
return views.size();
}
public int getPageIconResId(int paramInt) {
return EmojiView.this.icons[paramInt];
return icons[paramInt];
}
public Object instantiateItem(ViewGroup paramViewGroup, int paramInt) {
View localObject;
if (paramInt == 0) {
localObject = EmojiView.this.recentsWrap;
localObject = recentsWrap;
} else {
localObject = EmojiView.this.views.get(paramInt);
localObject = views.get(paramInt);
}
paramViewGroup.addView(localObject);
return localObject;

View File

@ -55,11 +55,9 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
private float currentPositionOffset = 0f;
private Paint rectPaint;
private Paint dividerPaint;
private int indicatorColor = 0xFF666666;
private int underlineColor = 0x1A000000;
private int dividerColor = 0x1A000000;
private boolean shouldExpand = false;
private boolean textAllCaps = true;
@ -69,7 +67,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
private int underlineHeight = 2;
private int dividerPadding = 12;
private int tabPadding = 24;
private int dividerWidth = 1;
private int tabTextSize = 12;
private int tabTextColor = 0xFF666666;
@ -108,17 +105,12 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);
rectPaint = new Paint();
rectPaint.setAntiAlias(true);
rectPaint.setStyle(Style.FILL);
dividerPaint = new Paint();
dividerPaint.setAntiAlias(true);
dividerPaint.setStrokeWidth(dividerWidth);
defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
if (locale == null) {
@ -322,14 +314,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
rectPaint.setColor(underlineColor);
canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
// draw divider
dividerPaint.setColor(dividerColor);
for (int i = 0; i < tabCount - 1; i++) {
View tab = tabsContainer.getChildAt(i);
canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
}
}
private class PageListener implements OnPageChangeListener {
@ -419,20 +403,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
return underlineColor;
}
public void setDividerColor(int dividerColor) {
this.dividerColor = dividerColor;
invalidate();
}
public void setDividerColorResource(int resId) {
this.dividerColor = getResources().getColor(resId);
invalidate();
}
public int getDividerColor() {
return dividerColor;
}
public void setUnderlineHeight(int underlineHeightPx) {
this.underlineHeight = underlineHeightPx;
invalidate();

View File

@ -525,7 +525,8 @@ public class Switch extends CompoundButton {
final int thumbLeft = thumbInitialLeft - padding.left;
final int thumbRight = thumbInitialLeft + mThumbWidth + padding.right;
mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
int offset = (AndroidUtilities.density == 1.5f ? AndroidUtilities.dp(1) : 0);
mThumbDrawable.setBounds(thumbLeft, switchTop + offset, thumbRight, switchBottom + offset);
final Drawable background = getBackground();
if (background != null) {

View File

@ -90,8 +90,8 @@ public class TimerDrawable extends Drawable {
@Override
public void draw(Canvas canvas) {
int width = canvas.getWidth();
int height = canvas.getHeight();
int width = getBounds().width();
int height = getBounds().height();
Drawable drawable = null;
if (time == 0) {
drawable = timerDrawable;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 929 B

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -111,7 +111,7 @@
android:layout_marginTop="2dp"
android:maxLines="4"
android:textSize="18dp"
android:textColorHint="#909090"
android:textColorHint="#b2b2b2"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textMultiLine"
@ -119,8 +119,9 @@
android:layout_marginLeft="52dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="4dp"
android:paddingBottom="10dp"
android:paddingBottom="8dp"
android:paddingTop="4dp"
android:background="@null"
android:textCursorDrawable="@null"
android:textColor="#000000"/>

View File

@ -51,9 +51,9 @@
android:layout_gravity="bottom"
android:id="@+id/chat_text_edit"
android:layout_marginTop="2dp"
android:maxLines="2"
android:maxLines="4"
android:textSize="18dp"
android:textColorHint="#909090"
android:textColorHint="#b2b2b2"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textMultiLine"
@ -61,8 +61,9 @@
android:layout_marginLeft="52dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="4dp"
android:paddingBottom="10dp"
android:paddingBottom="8dp"
android:paddingTop="4dp"
android:background="@null"
android:textCursorDrawable="@null"
android:textColor="#000000"/>

View File

@ -35,7 +35,7 @@
<item name="android:colorPrimaryDark">#33000000</item>
<item name="android:colorPrimary">#54759e</item>
<item name="android:alertDialogTheme">@style/Theme.TMessages.Dialog.Alert</item>
<item name="android:colorControlActivated">#678cb9</item>
<item name="android:colorControlActivated">#4d83b3</item>
</style>
<style name="Theme.TMessages.PopupNotification" parent="Theme.TMessages">
@ -47,7 +47,7 @@
</style>
<style name="Theme.TMessages.Dialog.Alert" parent="android:style/Theme.Material.Light.Dialog.Alert">
<item name="android:colorAccent">#678cb9</item>
<item name="android:colorAccent">#4d83b3</item>
</style>
<!--ACTION BAR-->

View File

@ -47,7 +47,7 @@
<string name="ClearHistory">Clear history</string>
<string name="DeleteChat">Delete and exit</string>
<string name="DeleteChatUser">Delete chat</string>
<string name="HiddenName">Hidden Name</string>
<string name="HiddenName">Deleted Account</string>
<string name="SelectChat">Select Chat</string>
<string name="PhotoTip">Tap and hold to view</string>
<string name="CompatibilityChat">%1$s is using an older version of Telegram, so secret photos will be shown in compatibility mode.\n\nOnce %2$s updates Telegram, photos with timers for 1 minute or less will start working in \'Tap and hold to view\' mode, and you will be notified whenever the other party takes a screenshot.</string>
@ -287,6 +287,7 @@
<string name="Gallery">Gallery</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<string name="PleaseDownload">Please download media first</string>
<!--privacy settings-->
<string name="PrivacySettings">Privacy and Security</string>
<string name="PrivacyTitle">Privacy</string>
@ -300,11 +301,10 @@
<string name="LastSeenContactsMinusPlus">My Contacts (-%1$d, +%2$d)</string>
<string name="LastSeenNobodyPlus">Nobody (+%1$d)</string>
<string name="SecurityTitle">Security</string>
<string name="DeleteAccountTitle">Delete my account</string>
<string name="DeleteAccountIfAwayFor">If Away For</string>
<string name="DeleteAccountTitle">Account self-destructs</string>
<string name="DeleteAccountIfAwayFor">If you\'re away for</string>
<string name="DeleteAccountHelp">If you do not log in at least once within this period, your account will be deleted along with all groups, messages and contacts.</string>
<string name="DeleteAccountNowConfirmation">Delete your account?</string>
<string name="DeleteAccountNever">Never</string>
<string name="LastSeenHelp">Change who can see your Last Seen time.</string>
<string name="LastSeenTitle">Who can see your Last Seen time?</string>
<string name="AddExceptions">Add exceptions</string>