update to 1.3.7

This commit is contained in:
DrKLO 2013-12-26 20:46:13 +04:00
parent 51add404ef
commit 9d2dfd33ee
32 changed files with 168 additions and 213 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.telegram.messenger"
android:versionCode="129"
android:versionName="1.3.6">
android:versionCode="131"
android:versionName="1.3.7">
<supports-screens android:anyDensity="true"
android:smallScreens="true"

View file

@ -8961,7 +8961,7 @@ public class TLRPC {
}
}
public static class TL_encryptedChat_old extends EncryptedChat {
public static class TL_encryptedChat_old extends TL_encryptedChat {
public static int constructor = 0x6601d14f;

View file

@ -659,6 +659,18 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
invoke.app_version = "App version unknown";
invoke.system_version = "SDK " + Build.VERSION.SDK_INT;
}
if (invoke.lang_code == null || invoke.lang_code.length() == 0) {
invoke.lang_code = "en";
}
if (invoke.device_model == null || invoke.device_model.length() == 0) {
invoke.device_model = "Android unknown";
}
if (invoke.app_version == null || invoke.app_version.length() == 0) {
invoke.app_version = "App version unknown";
}
if (invoke.system_version == null || invoke.system_version.length() == 0) {
invoke.system_version = "SDK Unknown";
}
object = invoke;
}
TLRPC.invokeWithLayer11 invoke = new TLRPC.invokeWithLayer11();

View file

@ -287,7 +287,7 @@ public class Emoji {
0x00000000D83DDD34L, 0x00000000D83DDD35L, 0x00000000D83DDD3BL, 0x00000000D83DDD36L, 0x00000000D83DDD37L, 0x00000000D83DDD38L, 0x00000000D83DDD39L}};
static {
imgSize = Math.min(scale(30), ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density < 1.5f ? 28 : 56);
imgSize = Math.min(scale(30), Utilities.density < 1.5f ? 28 : 56);
drawImgSize = scale(20);
bigImgSize = scale(30);
if(Math.abs(imgSize - bigImgSize) < 5) {
@ -317,7 +317,7 @@ public class Emoji {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
opts.inDither = false;
if (ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density < 1.5f) {
if (Utilities.density < 1.5f) {
opts.inSampleSize = 2;
}
@ -559,8 +559,8 @@ public class Emoji {
int sz = super.getSize(paint, text, start, end, fm);
int offset = (int)(8 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density);
int w = (int)(20 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density / 2);
int offset = Utilities.dp(8);
int w = Utilities.dp(10);
fm.top = -w - offset;
fm.bottom = w - offset;
fm.ascent = -w - offset;
@ -586,7 +586,7 @@ public class Emoji {
int sz = super.getSize(paint, text, start, end, fm);
int offset = (int)(6 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density);
int offset = Utilities.dp(6);
int w = (fm.bottom - fm.top) / 2;
fm.top = -w - offset;
fm.bottom = w - offset;

View file

@ -205,8 +205,8 @@ public class FileLoadOperation {
float h_filter;
if (filter != null) {
String args[] = filter.split("_");
w_filter = Float.parseFloat(args[0]) * FileLoader.Instance.density;
h_filter = Float.parseFloat(args[1]) * FileLoader.Instance.density;
w_filter = Float.parseFloat(args[0]) * Utilities.density;
h_filter = Float.parseFloat(args[1]) * Utilities.density;
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(cacheFileFinal.getAbsolutePath(), opts);
@ -399,8 +399,8 @@ public class FileLoadOperation {
float h_filter;
if (filter != null) {
String args[] = filter.split("_");
w_filter = Float.parseFloat(args[0]) * FileLoader.Instance.density;
h_filter = Float.parseFloat(args[1]) * FileLoader.Instance.density;
w_filter = Float.parseFloat(args[0]) * Utilities.density;
h_filter = Float.parseFloat(args[1]) * Utilities.density;
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(cacheFileFinal.getAbsolutePath(), opts);

View file

@ -53,7 +53,6 @@ public class FileLoader {
public static long lastCacheOutTime = 0;
public ConcurrentHashMap<String, Float> fileProgresses = new ConcurrentHashMap<String, Float>();
private long lastProgressUpdateTime = 0;
public float density = 1;
private HashMap<String, Integer> BitmapUseCounts = new HashMap<String, Integer>();
int lastImageNum;
@ -254,7 +253,6 @@ public class FileLoader {
public FileLoader() {
int cacheSize = Math.min(15, ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass() / 7) * 1024 * 1024;
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (Build.VERSION.SDK_INT < 11) {
runtimeHack = new VMRuntimeHack();
cacheSize = 1024 * 1024 * 3;

View file

@ -3364,6 +3364,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.system_version = "SDK " + Build.VERSION.SDK_INT;
req.app_version = "App version unknown";
}
if (req.lang_code == null || req.lang_code.length() == 0) {
req.lang_code = "en";
}
if (req.device_model == null || req.device_model.length() == 0) {
req.device_model = "Android unknown";
}
if (req.app_version == null || req.app_version.length() == 0) {
req.app_version = "App version unknown";
}
if (req.system_version == null || req.system_version.length() == 0) {
req.system_version = "SDK Unknown";
}
if (req.app_version != null) {
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override

View file

@ -48,6 +48,7 @@ public class MessagesStorage {
public void openDatabase() {
cacheFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "cache4.db");
boolean createTable = false;
//cacheFile.delete();
if (!cacheFile.exists()) {

View file

@ -56,6 +56,7 @@ import javax.crypto.Cipher;
public class Utilities {
public static Handler applicationHandler;
public static int statusBarHeight = 0;
public static float density = 1;
private final static Integer lock = 1;
public static ArrayList<String> goodPrimes = new ArrayList<String>();
@ -74,6 +75,7 @@ public class Utilities {
public native static byte[] aesIgeEncryption(byte[] _what, byte[] _key, byte[] _iv, boolean encrypt, boolean changeIv);
static {
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("primes", Context.MODE_PRIVATE);
String primes = preferences.getString("primes", null);
if (primes == null) {
@ -121,6 +123,10 @@ public class Utilities {
return new String(hexChars);
}
public static int dp(int value) {
return (int)(density * value);
}
public static boolean isGoodPrime(byte[] prime, int g) {
if (!(g >= 2 && g <= 7)) {
return false;

View file

@ -393,21 +393,20 @@ public class ApplicationActivity extends ActionBarActivity implements Notificati
public void onGlobalLayout() {
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
int rotation = manager.getDefaultDisplay().getRotation();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
int height;
int currentActionBarHeight = getSupportActionBar().getHeight();
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
if (currentActionBarHeight != Utilities.dp(48) && currentActionBarHeight != Utilities.dp(40)) {
height = currentActionBarHeight;
} else {
height = (int) (48.0f * density);
height = Utilities.dp(48);
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
height = (int) (40.0f * density);
height = Utilities.dp(40);
}
}
if (notificationView != null) {
notificationView.applyOrientationPaddings(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, density, height);
notificationView.applyOrientationPaddings(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
}
if (Build.VERSION.SDK_INT < 16) {
@ -579,17 +578,16 @@ public class ApplicationActivity extends ActionBarActivity implements Notificati
actionBar.setCustomView(statusView);
}
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
try {
if (statusView.getLayoutParams() instanceof android.support.v7.app.ActionBar.LayoutParams) {
android.support.v7.app.ActionBar.LayoutParams statusParams = (android.support.v7.app.ActionBar.LayoutParams)statusView.getLayoutParams();
statusText.measure(View.MeasureSpec.makeMeasureSpec(800, View.MeasureSpec.AT_MOST), 100);
statusParams.width = (int)(statusText.getMeasuredWidth() + 54 * density);
statusParams.width = (int)(statusText.getMeasuredWidth() + Utilities.dp(54));
statusView.setLayoutParams(statusParams);
} else if (statusView.getLayoutParams() instanceof android.app.ActionBar.LayoutParams) {
android.app.ActionBar.LayoutParams statusParams = (android.app.ActionBar.LayoutParams)statusView.getLayoutParams();
statusText.measure(View.MeasureSpec.makeMeasureSpec(800, View.MeasureSpec.AT_MOST), 100);
statusParams.width = (int)(statusText.getMeasuredWidth() + 54 * density);
statusParams.width = (int)(statusText.getMeasuredWidth() + Utilities.dp(54));
statusView.setLayoutParams(statusParams);
}
} catch (Exception e) {

View file

@ -117,7 +117,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private View progressView;
private boolean ignoreTextChange = false;
private TextView emptyView;
private float displayDensity;
private View bottomOverlay;
private TextView bottomOverlayText;
private MessageObject selectedObject;
@ -350,7 +349,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} else {
display.getSize(displaySize);
}
displayDensity = getResources().getDisplayMetrics().density;
}
@Override
@ -415,7 +413,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
secretChatPlaceholder.setBackgroundResource(R.drawable.system_blue);
}
secretViewStatusTextView = (TextView)contentView.findViewById(R.id.invite_text);
secretChatPlaceholder.setPadding((int)(16 * displayDensity), (int)(12 * displayDensity), (int)(16 * displayDensity), (int)(12 * displayDensity));
secretChatPlaceholder.setPadding(Utilities.dp(16), Utilities.dp(12), Utilities.dp(16), Utilities.dp(12));
View v = contentView.findViewById(R.id.secret_placeholder);
v.setVisibility(View.VISIBLE);
@ -444,7 +442,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
progressViewInner.setBackgroundResource(R.drawable.system_loader1);
emptyView.setBackgroundResource(R.drawable.system_blue);
}
emptyView.setPadding((int)(7 * displayDensity), (int)(1 * displayDensity), (int)(7 * displayDensity), (int)(1 * displayDensity));
emptyView.setPadding(Utilities.dp(7), Utilities.dp(1), Utilities.dp(7), Utilities.dp(1));
if (currentUser != null && currentUser.id == 333000) {
emptyView.setText(R.string.GotAQuestion);
@ -952,7 +950,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (title != null) {
if (currentEncryptedChat != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int)(4 * displayDensity));
title.setCompoundDrawablePadding(Utilities.dp(4));
} else {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
title.setCompoundDrawablePadding(0);
@ -1367,18 +1365,18 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
chatAdapter.notifyDataSetChanged();
if (positionToUnread && unreadMessageObject != null) {
if (messages.get(messages.size() - 1) == unreadMessageObject) {
chatListView.setSelectionFromTop(0, -(int)(11 * displayDensity));
chatListView.setSelectionFromTop(0, Utilities.dp(-11));
} else {
chatListView.setSelectionFromTop(messages.size() - messages.indexOf(unreadMessageObject), -(int)(11 * displayDensity));
chatListView.setSelectionFromTop(messages.size() - messages.indexOf(unreadMessageObject), Utilities.dp(-11));
}
ViewTreeObserver obs = chatListView.getViewTreeObserver();
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
if (messages.get(messages.size() - 1) == unreadMessageObject) {
chatListView.setSelectionFromTop(0, -(int)(11 * displayDensity));
chatListView.setSelectionFromTop(0, Utilities.dp(-11));
} else {
chatListView.setSelectionFromTop(messages.size() - messages.indexOf(unreadMessageObject), -(int)(11 * displayDensity));
chatListView.setSelectionFromTop(messages.size() - messages.indexOf(unreadMessageObject), Utilities.dp(-11));
}
chatListView.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
@ -1826,7 +1824,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
topPanel.setVisibility(View.GONE);
} else {
topPanel.setVisibility(View.VISIBLE);
topPanelText.setShadowLayer(1, 0, 1 * displayDensity, 0xff8797a3);
topPanelText.setShadowLayer(1, 0, Utilities.dp(1), 0xff8797a3);
if (isCustomTheme) {
topPlaneClose.setImageResource(R.drawable.ic_msg_btn_cross_custom);
topPanel.setBackgroundResource(R.drawable.top_pane_custom);
@ -1989,7 +1987,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (scrollToTopOnResume) {
if (scrollToTopUnReadOnResume && unreadMessageObject != null) {
if (chatListView != null) {
chatListView.setSelectionFromTop(messages.size() - messages.indexOf(unreadMessageObject), -chatListView.getPaddingTop() - (int)(7 * displayDensity));
chatListView.setSelectionFromTop(messages.size() - messages.indexOf(unreadMessageObject), -chatListView.getPaddingTop() - Utilities.dp(7));
}
} else {
if (chatListView != null) {
@ -2051,7 +2049,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} else {
subtitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.typing_dots, 0, 0, 0);
}
subtitle.setCompoundDrawablePadding((int)(4 * displayDensity));
subtitle.setCompoundDrawablePadding(Utilities.dp(4));
AnimationDrawable mAnim = (AnimationDrawable)subtitle.getCompoundDrawables()[0];
mAnim.setAlpha(200);
mAnim.start();
@ -2101,13 +2099,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
int rotation = display.getRotation();
int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
if (currentActionBarHeight != Utilities.dp(48) && currentActionBarHeight != Utilities.dp(40)) {
height = currentActionBarHeight;
} else {
height = (int) (48.0f * density);
height = Utilities.dp(48);
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
height = (int) (40.0f * density);
height = Utilities.dp(40);
}
}
@ -2128,7 +2126,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int) (4 * displayDensity));
title.setCompoundDrawablePadding(Utilities.dp(4));
}
}
@ -2691,22 +2689,22 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_photo_states);
} else if (messageType == 0 || messageType == 8) {
holder.messageLayout.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.messageLayout.setPadding((int)(11 * displayDensity), (int)(7 * displayDensity), (int)(18 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(11), Utilities.dp(7), Utilities.dp(18), 0);
} else if (messageType == 1 || messageType == 9) {
holder.messageLayout.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.messageLayout.setPadding((int)(19 * displayDensity), (int)(7 * displayDensity), (int)(9 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(19), Utilities.dp(7), Utilities.dp(9), 0);
} else if (messageType == 12) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.chatBubbleView.setPadding((int)(6 * displayDensity), (int)(6 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(6), Utilities.dp(6), Utilities.dp(18), 0);
} else if (messageType == 13) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(15), Utilities.dp(6), Utilities.dp(9), 0);
} else if (messageType == 16) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(9), Utilities.dp(9), Utilities.dp(18), 0);
} else if (messageType == 17) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(18), Utilities.dp(9), Utilities.dp(9), 0);
}
} else {
if (messageType == 2 || messageType == 4 || messageType == 6) {
@ -2727,42 +2725,42 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} else {
holder.messageLayout.setBackgroundResource(R.drawable.msg_out);
}
holder.messageLayout.setPadding((int)(11 * displayDensity), (int)(7 * displayDensity), (int)(18 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(11), Utilities.dp(7), Utilities.dp(18), 0);
} else if (messageType == 1 || messageType == 9) {
if (selected) {
holder.messageLayout.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.messageLayout.setBackgroundResource(R.drawable.msg_in);
}
holder.messageLayout.setPadding((int)(19 * displayDensity), (int)(7 * displayDensity), (int)(9 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(19), Utilities.dp(7), Utilities.dp(9), 0);
} else if (messageType == 12) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out);
}
holder.chatBubbleView.setPadding((int)(6 * displayDensity), (int)(6 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(6), Utilities.dp(6), Utilities.dp(18), 0);
} else if (messageType == 13) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in);
}
holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(15), Utilities.dp(6), Utilities.dp(9), 0);
} else if (messageType == 16) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out);
}
holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(9), Utilities.dp(9), Utilities.dp(18), 0);
} else if (messageType == 17) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in);
}
holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(18), Utilities.dp(9), Utilities.dp(9), 0);
}
}
}
@ -2934,22 +2932,22 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_photo_states);
} else if (messageType == 0 || messageType == 8) {
holder.messageLayout.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.messageLayout.setPadding((int)(11 * displayDensity), (int)(7 * displayDensity), (int)(18 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(11), Utilities.dp(7), Utilities.dp(18), 0);
} else if (messageType == 1 || messageType == 9) {
holder.messageLayout.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.messageLayout.setPadding((int)(19 * displayDensity), (int)(7 * displayDensity), (int)(9 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(19), Utilities.dp(7), Utilities.dp(9), 0);
} else if (messageType == 12) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.chatBubbleView.setPadding((int)(6 * displayDensity), (int)(6 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(6), Utilities.dp(6), Utilities.dp(18), 0);
} else if (messageType == 13) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(15), Utilities.dp(6), Utilities.dp(9), 0);
} else if (messageType == 16) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(9), Utilities.dp(9), Utilities.dp(18), 0);
} else if (messageType == 17) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(18), Utilities.dp(9), Utilities.dp(9), 0);
}
} else {
if (messageType == 2 || messageType == 4 || messageType == 6) {
@ -2970,42 +2968,42 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} else {
holder.messageLayout.setBackgroundResource(R.drawable.msg_out);
}
holder.messageLayout.setPadding((int)(11 * displayDensity), (int)(7 * displayDensity), (int)(18 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(11), Utilities.dp(7), Utilities.dp(18), 0);
} else if (messageType == 1 || messageType == 9) {
if (selected) {
holder.messageLayout.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.messageLayout.setBackgroundResource(R.drawable.msg_in);
}
holder.messageLayout.setPadding((int)(19 * displayDensity), (int)(7 * displayDensity), (int)(9 * displayDensity), 0);
holder.messageLayout.setPadding(Utilities.dp(19), Utilities.dp(7), Utilities.dp(9), 0);
} else if (messageType == 12) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out);
}
holder.chatBubbleView.setPadding((int)(6 * displayDensity), (int)(6 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(6), Utilities.dp(6), Utilities.dp(18), 0);
} else if (messageType == 13) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in);
}
holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(15), Utilities.dp(6), Utilities.dp(9), 0);
} else if (messageType == 16) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out);
}
holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(9), Utilities.dp(9), Utilities.dp(18), 0);
} else if (messageType == 17) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in);
}
holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0);
holder.chatBubbleView.setPadding(Utilities.dp(18), Utilities.dp(9), Utilities.dp(9), 0);
}
}
@ -3084,11 +3082,10 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (type == 0 || type == 1 || type == 8 || type == 9) {
int width;
if (currentChat != null && (type == 1 || type == 9)) {
width = displaySize.x - (int)(122 * displayDensity);
width = displaySize.x - Utilities.dp(122);
} else {
width = displaySize.x - (int)(80 * displayDensity);
width = displaySize.x - Utilities.dp(80);
}
messageLayout.density = displayDensity;
messageLayout.maxWidth = width;
messageLayout.messageTextView.setText(message.messageText);
messageLayout.messageTextView.setMaxWidth(width);
@ -3124,18 +3121,18 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (photo != null) {
float scale = (float)photo.photoOwner.w / (float)width;
if (scale < 1 && photo.photoOwner.w * scale < 100 * displayDensity) {
scale = photo.photoOwner.w / (100 * displayDensity);
if (scale < 1 && photo.photoOwner.w * scale < Utilities.dp(100)) {
scale = photo.photoOwner.w / Utilities.dp(100);
}
int w = (int)(photo.photoOwner.w / scale);
int h = (int)(photo.photoOwner.h / scale);
if (h > 160 * displayDensity) {
if (h > Utilities.dp(160)) {
float scale2 = h;
h = (int)(160 * displayDensity);
h = Utilities.dp(160);
scale2 /= h;
w = (int)(w / scale2);
} else if (h < 90 * displayDensity) {
h = (int)(90 * displayDensity);
} else if (h < Utilities.dp(90)) {
h = Utilities.dp(90);
float hScale = (float)photo.photoOwner.h / h;
if (photo.photoOwner.w / hScale < width) {
w = (int)(photo.photoOwner.w / hScale);
@ -3151,9 +3148,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
photoImage.setImageBitmap(photo.image);
} else {
if (message.imagePreview != null) {
photoImage.setImage(photo.photoOwner.location, String.format(Locale.US, "%d_%d", (int)(w / displayDensity), (int)(h / displayDensity)), message.imagePreview);
photoImage.setImage(photo.photoOwner.location, String.format(Locale.US, "%d_%d", (int)(w / Utilities.density), (int)(h / Utilities.density)), message.imagePreview);
} else {
photoImage.setImage(photo.photoOwner.location, String.format(Locale.US, "%d_%d", (int)(w / displayDensity), (int)(h / displayDensity)), message.messageOwner.out ? R.drawable.photo_placeholder_out : R.drawable.photo_placeholder_in);
photoImage.setImage(photo.photoOwner.location, String.format(Locale.US, "%d_%d", (int)(w / Utilities.density), (int)(h / Utilities.density)), message.messageOwner.out ? R.drawable.photo_placeholder_out : R.drawable.photo_placeholder_in);
}
}
}
@ -3167,11 +3164,10 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} else if (type == 4 || type == 5) {
double lat = message.messageOwner.media.geo.lat;
double lon = message.messageOwner.media.geo._long;
String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(displayDensity)), lat, lon);
String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(Utilities.density)), lat, lon);
photoImage.setImage(url, null, message.messageOwner.out ? R.drawable.photo_placeholder_out : R.drawable.photo_placeholder_in);
} else if (type == 11 || type == 10) {
int width = (int)(displaySize.x - (30 * displayDensity));
messageLayoutAction.density = displayDensity;
int width = displaySize.x - Utilities.dp(30);
messageTextView.setText(message.messageText);
messageTextView.setMaxWidth(width);
@ -3179,7 +3175,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (message.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
photoImage.setImage(message.messageOwner.action.newUserPhoto.photo_small, "50_50", Utilities.getUserAvatarForId(currentUser.id));
} else {
PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, (int)(64 * displayDensity), (int)(64 * displayDensity));
PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, Utilities.dp(64), Utilities.dp(64));
if (photo.image != null) {
photoImage.setImageBitmap(photo.image);
} else {
@ -3413,15 +3409,15 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
int width;
if (currentChat != null && type != 16) {
if (actionView.getVisibility() == View.VISIBLE) {
width = displaySize.x - (int)(290 * displayDensity);
width = displaySize.x - Utilities.dp(290);
} else {
width = displaySize.x - (int)(270 * displayDensity);
width = displaySize.x - Utilities.dp(270);
}
} else {
if (actionView.getVisibility() == View.VISIBLE) {
width = displaySize.x - (int)(240 * displayDensity);
width = displaySize.x - Utilities.dp(240);
} else {
width = displaySize.x - (int)(220 * displayDensity);
width = displaySize.x - Utilities.dp(220);
}
}
nameTextView.setMaxWidth(width);

View file

@ -502,8 +502,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if (s.length() != 0) {
searchWas = true;
if (listView != null) {
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 16), listView.getPaddingBottom());
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
listView.setAdapter(searchListViewAdapter);
if(android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false);
@ -538,11 +537,10 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
searchWas = false;
ViewGroup group = (ViewGroup) listView.getParent();
listView.setAdapter(listViewAdapter);
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (!isRTL) {
listView.setPadding((int) (density * 16), listView.getPaddingTop(), (int) (density * 30), listView.getPaddingBottom());
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
} else {
listView.setPadding((int) (density * 30), listView.getPaddingTop(), (int) (density * 16), listView.getPaddingBottom());
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
}
if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(true);

View file

@ -228,8 +228,7 @@ public class CountrySelectActivity extends ActionBarActivity {
if (s.length() != 0) {
searchWas = true;
if (listView != null) {
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 16), listView.getPaddingBottom());
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
listView.setAdapter(searchListViewAdapter);
if(android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false);
@ -261,11 +260,10 @@ public class CountrySelectActivity extends ActionBarActivity {
searchWas = false;
ViewGroup group = (ViewGroup) listView.getParent();
listView.setAdapter(listViewAdapter);
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (!isRTL) {
listView.setPadding((int) (density * 16), listView.getPaddingTop(), (int) (density * 30), listView.getPaddingBottom());
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
} else {
listView.setPadding((int) (density * 30), listView.getPaddingTop(), (int) (density * 16), listView.getPaddingBottom());
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
}
if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(true);

View file

@ -182,9 +182,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
}
}
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
mViewPager.setPageMargin((int)(20 * density));
mViewPager.setPageMargin(Utilities.dp(20));
mViewPager.setOffscreenPageLimit(1);
mViewPager.setAdapter(localPagerAdapter);
@ -357,8 +355,8 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (title != null) {
fakeTitleView.setText(String.format("%d %s %d", pos, getString(R.string.Of), totalCount));
fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40);
title.setWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density));
title.setWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
}
}
});
@ -778,8 +776,8 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (title != null) {
fakeTitleView.setText(String.format("%d %s %d", (totalCount - imagesArr.size()) + position + 1, getString(R.string.Of), totalCount));
fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40);
title.setWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density));
title.setWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
}
}
});
@ -797,8 +795,8 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (title != null) {
fakeTitleView.setText(String.format("%d %s %d", position + 1, getString(R.string.Of), imagesArrLocations.size()));
fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40);
title.setWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density));
title.setWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
}
}
});

View file

@ -25,6 +25,7 @@ import android.widget.TextView;
import org.telegram.TL.TLRPC;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.BaseFragment;
import org.telegram.ui.Views.IdenticonView;
@ -91,7 +92,7 @@ public class IdenticonActivity extends BaseFragment {
}
if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int)(4 * getResources().getDisplayMetrics().density));
title.setCompoundDrawablePadding(Utilities.dp(4));
}
}
@ -125,7 +126,6 @@ public class IdenticonActivity extends BaseFragment {
LinearLayout layout = (LinearLayout)fragmentView;
WindowManager manager = (WindowManager)parentActivity.getSystemService(Context.WINDOW_SERVICE);
int rotation = manager.getDefaultDisplay().getRotation();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
layout.setOrientation(LinearLayout.HORIZONTAL);
@ -143,7 +143,7 @@ public class IdenticonActivity extends BaseFragment {
}
if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int)(4 * density));
title.setCompoundDrawablePadding(Utilities.dp(4));
}
return false;

View file

@ -30,10 +30,8 @@ public class IntroActivity extends ActionBarActivity {
private ViewPager viewPager;
private ImageView topImage1;
private ImageView topImage2;
private TextView startMessagingButton;
private ViewGroup bottomPages;
private int lastPage = 0;
private float density = 1;
private boolean isRTL = false;
private boolean justCreated = false;
private boolean startPressed = false;
@ -107,9 +105,8 @@ public class IntroActivity extends ActionBarActivity {
R.string.Page7Message
};
}
density = getResources().getDisplayMetrics().density;
viewPager = (ViewPager)findViewById(R.id.intro_view_pager);
startMessagingButton = (TextView)findViewById(R.id.start_messaging_button);
TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
topImage1 = (ImageView)findViewById(R.id.icon_image1);
topImage2 = (ImageView)findViewById(R.id.icon_image2);
bottomPages = (ViewGroup)findViewById(R.id.bottom_pages);

View file

@ -8,10 +8,7 @@
package org.telegram.ui;
import android.app.Activity;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.LayoutInflater;
@ -32,7 +29,6 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import org.telegram.TL.TLRPC;
import org.telegram.messenger.FileLog;
import org.telegram.objects.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
@ -41,10 +37,9 @@ import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.BaseFragment;
public class LocationActivity extends BaseFragment implements LocationListener, NotificationCenter.NotificationCenterDelegate {
public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private GoogleMap googleMap;
private TextView distanceTextView;
private Marker myLocationMarker;
private Marker userMarker;
private Location myLocation;
private Location userLocation;
@ -60,16 +55,22 @@ public class LocationActivity extends BaseFragment implements LocationListener,
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setupLocationListener();
googleMap = getMap();
if (googleMap == null) {
return;
}
googleMap.setMyLocationEnabled(false);
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.getUiSettings().setZoomControlsEnabled(false);
googleMap.getUiSettings().setCompassEnabled(false);
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
positionMarker(location);
}
});
myLocation = googleMap.getMyLocation();
if (sendButton != null) {
userLocation = new Location("network");
@ -160,8 +161,6 @@ public class LocationActivity extends BaseFragment implements LocationListener,
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
LocationManager locationManager = (LocationManager)parentActivity.getSystemService(Activity.LOCATION_SERVICE);
locationManager.removeUpdates(this);
NotificationCenter.Instance.removeObserver(this, MessagesController.updateInterfaces);
NotificationCenter.Instance.removeObserver(this, MessagesController.closeChats);
}
@ -295,47 +294,11 @@ public class LocationActivity extends BaseFragment implements LocationListener,
return true;
}
private void setupLocationListener() {
try {
LocationManager locationManager = (LocationManager)parentActivity.getSystemService(Activity.LOCATION_SERVICE);
boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
Location location = null;
if (isGPSEnabled || isNetworkEnabled) {
if (isGPSEnabled) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000 * 3 * 1, 1, this);
if (locationManager != null) {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}
}
if (location == null && isNetworkEnabled) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 3 * 1, 1, this);
if (locationManager != null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
}
}
positionMarker(location);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
private void positionMarker(Location location) {
if (location == null) {
return;
}
myLocation = location;
if (myLocationMarker == null) {
if (googleMap != null) {
myLocationMarker = googleMap.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(), location.getLongitude())).
icon(BitmapDescriptorFactory.fromResource(R.drawable.map_dot)).anchor(0.5f, 0.5f));
}
} else {
myLocationMarker.setPosition(new LatLng(location.getLatitude(), location.getLongitude()));
}
if (messageObject != null) {
if (userLocation != null && distanceTextView != null) {
float distance = location.distanceTo(userLocation);
@ -363,28 +326,6 @@ public class LocationActivity extends BaseFragment implements LocationListener,
}
@Override
public void onLocationChanged(final Location location) {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
positionMarker(location);
}
});
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == MessagesController.updateInterfaces) {

View file

@ -82,13 +82,13 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2);
getSupportActionBar().show();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
ImageView view = (ImageView)findViewById(16908332);
if (view == null) {
view = (ImageView)findViewById(R.id.home);
}
if (view != null) {
view.setPadding((int)(density * 6), 0, (int)(density * 6), 0);
view.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
}
views[0] = (SlideView)findViewById(R.id.login_page1);

View file

@ -306,6 +306,9 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
req.sms_type = 0;
req.phone_number = phone;
req.lang_code = Locale.getDefault().getCountry();
if (req.lang_code == null || req.lang_code.length() == 0) {
req.lang_code = "en";
}
final Bundle params = new Bundle();
params.putString("phone", "+" + codeField.getText() + phoneField.getText());

View file

@ -28,6 +28,7 @@ import android.widget.GridView;
import android.widget.TextView;
import org.telegram.TL.TLRPC;
import org.telegram.messenger.Utilities;
import org.telegram.objects.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
@ -289,20 +290,19 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
public boolean onPreDraw() {
WindowManager manager = (WindowManager)parentActivity.getSystemService(Activity.WINDOW_SERVICE);
int rotation = manager.getDefaultDisplay().getRotation();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
orientation = 1;
listView.setNumColumns(6);
itemWidth = getResources().getDisplayMetrics().widthPixels / 6 - (int)(2 * density) * 5;
itemWidth = getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5;
listView.setColumnWidth(itemWidth);
} else {
orientation = 0;
listView.setNumColumns(4);
itemWidth = getResources().getDisplayMetrics().widthPixels / 4 - (int)(2 * density) * 3;
itemWidth = getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3;
listView.setColumnWidth(itemWidth);
}
listView.setPadding(listView.getPaddingLeft(), (int)(4 * density), listView.getPaddingRight(), listView.getPaddingBottom());
listView.setPadding(listView.getPaddingLeft(), Utilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom());
listAdapter.notifyDataSetChanged();
listView.getViewTreeObserver().removeOnPreDrawListener(this);

View file

@ -70,7 +70,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private static boolean dialogsLoaded = false;
private boolean searching = false;
private boolean searchWas = false;
private float density = 1;
private boolean onlySelect = false;
private int activityToken = (int)(MessagesController.random.nextDouble() * Integer.MAX_VALUE);
private long selectedDialog;
@ -88,7 +87,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
NotificationCenter.Instance.addObserver(this, MessagesController.dialogsNeedReload);
NotificationCenter.Instance.addObserver(this, 999);
NotificationCenter.Instance.addObserver(this, MessagesController.updateInterfaces);
@ -324,7 +322,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
view = (ImageView)parentActivity.findViewById(R.id.home);
}
if (view != null) {
view.setPadding((int)(density * 6), 0, (int)(density * 6), 0);
view.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
}
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
@ -752,7 +750,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
View v = view.findViewById(R.id.settings_row_divider);
v.setVisibility(View.VISIBLE);
view.setPadding((int)(11 * density), 0, (int)(11 * density), 0);
view.setPadding(Utilities.dp(11), 0, Utilities.dp(11), 0);
}
MessagesListSearchRowHolder holder = (MessagesListSearchRowHolder)view.getTag();
if (holder == null) {
@ -781,7 +779,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else {
holder.nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_lock_green, 0);
}
holder.nameTextView.setCompoundDrawablePadding((int)(4 * density));
holder.nameTextView.setCompoundDrawablePadding(Utilities.dp(4));
} else {
holder.nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
holder.nameTextView.setCompoundDrawablePadding(0);
@ -972,7 +970,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else {
nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_lock_green, 0);
}
nameTextView.setCompoundDrawablePadding((int)(4 * density));
nameTextView.setCompoundDrawablePadding(Utilities.dp(4));
} else {
Log.e("test", "tda");
}

View file

@ -75,7 +75,7 @@ public class SettingsChangeNameActivity extends BaseFragment {
doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (firstNameField.getText().length() != 0 && lastNameField.getText().length() != 0) {
if (firstNameField.getText().length() != 0) {
saveName();
finishFragment();
}

View file

@ -52,7 +52,6 @@ import java.util.HashMap;
public class SettingsWallpapersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private HorizontalListView listView;
private ListAdapter listAdapter;
private float density;
private ImageView backgroundImage;
private ProgressBar progressBar;
private int selectedBackground;
@ -95,7 +94,6 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
if (fragmentView == null) {
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
listAdapter = new ListAdapter(parentActivity);
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
progressBar = (ProgressBar)fragmentView.findViewById(R.id.action_progress);
backgroundImage = (ImageView)fragmentView.findViewById(R.id.background_image);
@ -152,7 +150,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
boolean done;
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, (int) (320 * density), (int) (480 * density));
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(320), Utilities.dp(480));
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
File f = new File(Utilities.getCacheDir(), fileName);
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
@ -195,7 +193,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
if (requestCode == 0) {
Utilities.addMediaToGallery(currentPicturePath);
try {
Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, (int)(320 * density), (int)(480 * density));
Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, Utilities.dp(320), Utilities.dp(480));
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
FileOutputStream stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
@ -220,7 +218,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
}
cursor.close();
Bitmap bitmap = FileLoader.loadBitmap(imageFilePath, (int)(320 * density), (int)(480 * density));
Bitmap bitmap = FileLoader.loadBitmap(imageFilePath, Utilities.dp(320), Utilities.dp(480));
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
FileOutputStream stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
@ -237,7 +235,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
private void processSelectedBackground() {
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
if (selectedBackground != -1 && selectedBackground != 1000001 && wallPaper != null && wallPaper instanceof TLRPC.TL_wallPaper) {
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, (int)(320 * density), (int)(480 * density));
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(320), Utilities.dp(480));
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
File f = new File(Utilities.getCacheDir(), fileName);
if (!f.exists()) {
@ -509,7 +507,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
BackupImageView image = (BackupImageView)view.findViewById(R.id.image);
View selection = view.findViewById(R.id.selection);
TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, (int)(100 * density), (int)(100 * density));
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(100), Utilities.dp(100));
image.setImage(size.location, "100_100", 0);
if (wallPaper.id == selectedBackground) {
selection.setVisibility(View.VISIBLE);

View file

@ -345,7 +345,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
if (title != null) {
if (dialog_id != 0) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int)(4 * getResources().getDisplayMetrics().density));
title.setCompoundDrawablePadding(Utilities.dp(4));
} else {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
title.setCompoundDrawablePadding(0);
@ -392,7 +392,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}
if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int)(4 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density));
title.setCompoundDrawablePadding(Utilities.dp(4));
}
}
return false;

View file

@ -11,10 +11,10 @@ package org.telegram.ui.Views;
import android.widget.FrameLayout;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
public class MessageActionLayout extends FrameLayout {
public TightTextView messageTextView;
public float density = 1;
public MessageActionLayout(android.content.Context context) {
super(context);
@ -31,7 +31,7 @@ public class MessageActionLayout extends FrameLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(messageTextView.linesMaxWidth + (int)(14 * density), getMeasuredHeight());
setMeasuredDimension(messageTextView.linesMaxWidth + Utilities.dp(14), getMeasuredHeight());
}
@Override

View file

@ -12,12 +12,12 @@ import android.view.View;
import android.widget.TextView;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
public class MessageLayout extends FrameLayoutFixed {
public TextView timeTextView;
public View timeLayout;
public TightTextView messageTextView;
public float density = 1;
public int maxWidth;
public MessageLayout(android.content.Context context) {
@ -38,18 +38,17 @@ public class MessageLayout extends FrameLayoutFixed {
int timeWidth = timeLayout != null ? timeLayout.getMeasuredWidth() : timeTextView.getMeasuredWidth();
int totalWidth = getMeasuredWidth();
int maxChildWidth = getChildAt(0).getMeasuredWidth();
int count = getChildCount();
for (int a = 1; a < count - 1; a++) {
maxChildWidth = Math.max(maxChildWidth, getChildAt(a).getMeasuredWidth());
}
int timeMore = (int)(timeWidth + 6 * density);
int timeMore = timeWidth + Utilities.dp(6);
int fields = totalWidth - Math.max(maxChildWidth, timeWidth);
int height = getMeasuredHeight();
if (maxWidth - messageTextView.lastLineWidth < timeMore) {
setMeasuredDimension(Math.max(maxChildWidth, messageTextView.lastLineWidth) + fields, (int)(height + 14 * density));
setMeasuredDimension(Math.max(maxChildWidth, messageTextView.lastLineWidth) + fields, height + Utilities.dp(14));
} else {
int diff = maxChildWidth - messageTextView.lastLineWidth;
if (diff >= 0 && diff <= timeMore) {

View file

@ -289,7 +289,7 @@ public class NotificationView extends LinearLayout {
}
}
public void applyOrientationPaddings(boolean isLandscape, float density, int height) {
public void applyOrientationPaddings(boolean isLandscape, int height) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)avatarImage.getLayoutParams();
params.width = height;
params.height = height;
@ -298,22 +298,22 @@ public class NotificationView extends LinearLayout {
if (isLandscape) {
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
nameTextView.setPadding(0, (int)(2 * density), 0, 0);
messageTextView.setPadding(0, (int)(18 * density), 0, 0);
nameTextView.setPadding(0, Utilities.dp(2), 0, 0);
messageTextView.setPadding(0, Utilities.dp(18), 0, 0);
if (isRTL) {
params1.setMargins((int)(40 * density), 0, (int)(height + 6 * density), 0);
params1.setMargins(Utilities.dp(40), 0, height + Utilities.dp(6), 0);
} else {
params1.setMargins((int)(height + 6 * density), 0, (int)(40 * density), 0);
params1.setMargins(height + Utilities.dp(6), 0, Utilities.dp(40), 0);
}
} else {
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
nameTextView.setPadding(0, (int)(4 * density), 0, 0);
messageTextView.setPadding(0, (int) (24 * density), 0, 0);
nameTextView.setPadding(0, Utilities.dp(4), 0, 0);
messageTextView.setPadding(0, Utilities.dp(24), 0, 0);
if (isRTL) {
params1.setMargins((int)(40 * density), 0, (int)(height + 8 * density), 0);
params1.setMargins(Utilities.dp(40), 0, height + Utilities.dp(8), 0);
} else {
params1.setMargins((int)(height + 8 * density), 0, (int)(40 * density), 0);
params1.setMargins(height + Utilities.dp(8), 0, Utilities.dp(40), 0);
}
}
textLayout.setLayoutParams(params1);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB