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"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.telegram.messenger" package="org.telegram.messenger"
android:versionCode="129" android:versionCode="131"
android:versionName="1.3.6"> android:versionName="1.3.7">
<supports-screens android:anyDensity="true" <supports-screens android:anyDensity="true"
android:smallScreens="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; 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.app_version = "App version unknown";
invoke.system_version = "SDK " + Build.VERSION.SDK_INT; 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; object = invoke;
} }
TLRPC.invokeWithLayer11 invoke = new TLRPC.invokeWithLayer11(); TLRPC.invokeWithLayer11 invoke = new TLRPC.invokeWithLayer11();

View File

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

View File

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

View File

@ -53,7 +53,6 @@ public class FileLoader {
public static long lastCacheOutTime = 0; public static long lastCacheOutTime = 0;
public ConcurrentHashMap<String, Float> fileProgresses = new ConcurrentHashMap<String, Float>(); public ConcurrentHashMap<String, Float> fileProgresses = new ConcurrentHashMap<String, Float>();
private long lastProgressUpdateTime = 0; private long lastProgressUpdateTime = 0;
public float density = 1;
private HashMap<String, Integer> BitmapUseCounts = new HashMap<String, Integer>(); private HashMap<String, Integer> BitmapUseCounts = new HashMap<String, Integer>();
int lastImageNum; int lastImageNum;
@ -254,7 +253,6 @@ public class FileLoader {
public FileLoader() { public FileLoader() {
int cacheSize = Math.min(15, ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass() / 7) * 1024 * 1024; 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) { if (Build.VERSION.SDK_INT < 11) {
runtimeHack = new VMRuntimeHack(); runtimeHack = new VMRuntimeHack();
cacheSize = 1024 * 1024 * 3; 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.system_version = "SDK " + Build.VERSION.SDK_INT;
req.app_version = "App version unknown"; 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) { if (req.app_version != null) {
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -228,8 +228,7 @@ public class CountrySelectActivity extends ActionBarActivity {
if (s.length() != 0) { if (s.length() != 0) {
searchWas = true; searchWas = true;
if (listView != null) { if (listView != null) {
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density; listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 16), listView.getPaddingBottom());
listView.setAdapter(searchListViewAdapter); listView.setAdapter(searchListViewAdapter);
if(android.os.Build.VERSION.SDK_INT >= 11) { if(android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false); listView.setFastScrollAlwaysVisible(false);
@ -261,11 +260,10 @@ public class CountrySelectActivity extends ActionBarActivity {
searchWas = false; searchWas = false;
ViewGroup group = (ViewGroup) listView.getParent(); ViewGroup group = (ViewGroup) listView.getParent();
listView.setAdapter(listViewAdapter); listView.setAdapter(listViewAdapter);
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (!isRTL) { 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 { } 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) { if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(true); 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(Utilities.dp(20));
mViewPager.setPageMargin((int)(20 * density));
mViewPager.setOffscreenPageLimit(1); mViewPager.setOffscreenPageLimit(1);
mViewPager.setAdapter(localPagerAdapter); mViewPager.setAdapter(localPagerAdapter);
@ -357,8 +355,8 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (title != null) { if (title != null) {
fakeTitleView.setText(String.format("%d %s %d", pos, getString(R.string.Of), totalCount)); fakeTitleView.setText(String.format("%d %s %d", pos, getString(R.string.Of), totalCount));
fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40); fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40);
title.setWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density)); title.setWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density)); title.setMaxWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
} }
} }
}); });
@ -778,8 +776,8 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (title != null) { if (title != null) {
fakeTitleView.setText(String.format("%d %s %d", (totalCount - imagesArr.size()) + position + 1, getString(R.string.Of), totalCount)); 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); fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40);
title.setWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density)); title.setWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density)); title.setMaxWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
} }
} }
}); });
@ -797,8 +795,8 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if (title != null) { if (title != null) {
fakeTitleView.setText(String.format("%d %s %d", position + 1, getString(R.string.Of), imagesArrLocations.size())); 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); fakeTitleView.measure(View.MeasureSpec.makeMeasureSpec(400, View.MeasureSpec.AT_MOST), 40);
title.setWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density)); title.setWidth(fakeTitleView.getMeasuredWidth() + Utilities.dp(8));
title.setMaxWidth(fakeTitleView.getMeasuredWidth() + (int)(8 * getResources().getDisplayMetrics().density)); 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.TL.TLRPC;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.BaseFragment; import org.telegram.ui.Views.BaseFragment;
import org.telegram.ui.Views.IdenticonView; import org.telegram.ui.Views.IdenticonView;
@ -91,7 +92,7 @@ public class IdenticonActivity extends BaseFragment {
} }
if (title != null) { if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0); 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; LinearLayout layout = (LinearLayout)fragmentView;
WindowManager manager = (WindowManager)parentActivity.getSystemService(Context.WINDOW_SERVICE); WindowManager manager = (WindowManager)parentActivity.getSystemService(Context.WINDOW_SERVICE);
int rotation = manager.getDefaultDisplay().getRotation(); int rotation = manager.getDefaultDisplay().getRotation();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
layout.setOrientation(LinearLayout.HORIZONTAL); layout.setOrientation(LinearLayout.HORIZONTAL);
@ -143,7 +143,7 @@ public class IdenticonActivity extends BaseFragment {
} }
if (title != null) { if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0); title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
title.setCompoundDrawablePadding((int)(4 * density)); title.setCompoundDrawablePadding(Utilities.dp(4));
} }
return false; return false;

View File

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

View File

@ -8,10 +8,7 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.Activity;
import android.location.Location; import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.view.LayoutInflater; 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.Marker;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
import org.telegram.TL.TLRPC; import org.telegram.TL.TLRPC;
import org.telegram.messenger.FileLog;
import org.telegram.objects.MessageObject; import org.telegram.objects.MessageObject;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; 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.BackupImageView;
import org.telegram.ui.Views.BaseFragment; 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 GoogleMap googleMap;
private TextView distanceTextView; private TextView distanceTextView;
private Marker myLocationMarker;
private Marker userMarker; private Marker userMarker;
private Location myLocation; private Location myLocation;
private Location userLocation; private Location userLocation;
@ -60,16 +55,22 @@ public class LocationActivity extends BaseFragment implements LocationListener,
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
setupLocationListener();
googleMap = getMap(); googleMap = getMap();
if (googleMap == null) { if (googleMap == null) {
return; return;
} }
googleMap.setMyLocationEnabled(false); googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(false); googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.getUiSettings().setZoomControlsEnabled(false); googleMap.getUiSettings().setZoomControlsEnabled(false);
googleMap.getUiSettings().setCompassEnabled(false); googleMap.getUiSettings().setCompassEnabled(false);
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
positionMarker(location);
}
});
myLocation = googleMap.getMyLocation();
if (sendButton != null) { if (sendButton != null) {
userLocation = new Location("network"); userLocation = new Location("network");
@ -160,8 +161,6 @@ public class LocationActivity extends BaseFragment implements LocationListener,
@Override @Override
public void onFragmentDestroy() { public void onFragmentDestroy() {
super.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.updateInterfaces);
NotificationCenter.Instance.removeObserver(this, MessagesController.closeChats); NotificationCenter.Instance.removeObserver(this, MessagesController.closeChats);
} }
@ -295,47 +294,11 @@ public class LocationActivity extends BaseFragment implements LocationListener,
return true; 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) { private void positionMarker(Location location) {
if (location == null) { if (location == null) {
return; return;
} }
myLocation = location; 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 (messageObject != null) {
if (userLocation != null && distanceTextView != null) { if (userLocation != null && distanceTextView != null) {
float distance = location.distanceTo(userLocation); 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 @Override
public void didReceivedNotification(int id, Object... args) { public void didReceivedNotification(int id, Object... args) {
if (id == MessagesController.updateInterfaces) { 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().setLogo(R.drawable.ab_icon_fixed2);
getSupportActionBar().show(); getSupportActionBar().show();
float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
ImageView view = (ImageView)findViewById(16908332); ImageView view = (ImageView)findViewById(16908332);
if (view == null) { if (view == null) {
view = (ImageView)findViewById(R.id.home); view = (ImageView)findViewById(R.id.home);
} }
if (view != null) { 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); 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.sms_type = 0;
req.phone_number = phone; req.phone_number = phone;
req.lang_code = Locale.getDefault().getCountry(); 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(); final Bundle params = new Bundle();
params.putString("phone", "+" + codeField.getText() + phoneField.getText()); params.putString("phone", "+" + codeField.getText() + phoneField.getText());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,12 +12,12 @@ import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
public class MessageLayout extends FrameLayoutFixed { public class MessageLayout extends FrameLayoutFixed {
public TextView timeTextView; public TextView timeTextView;
public View timeLayout; public View timeLayout;
public TightTextView messageTextView; public TightTextView messageTextView;
public float density = 1;
public int maxWidth; public int maxWidth;
public MessageLayout(android.content.Context context) { public MessageLayout(android.content.Context context) {
@ -38,18 +38,17 @@ public class MessageLayout extends FrameLayoutFixed {
int timeWidth = timeLayout != null ? timeLayout.getMeasuredWidth() : timeTextView.getMeasuredWidth(); int timeWidth = timeLayout != null ? timeLayout.getMeasuredWidth() : timeTextView.getMeasuredWidth();
int totalWidth = getMeasuredWidth(); int totalWidth = getMeasuredWidth();
int maxChildWidth = getChildAt(0).getMeasuredWidth(); int maxChildWidth = getChildAt(0).getMeasuredWidth();
int count = getChildCount(); int count = getChildCount();
for (int a = 1; a < count - 1; a++) { for (int a = 1; a < count - 1; a++) {
maxChildWidth = Math.max(maxChildWidth, getChildAt(a).getMeasuredWidth()); 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 fields = totalWidth - Math.max(maxChildWidth, timeWidth);
int height = getMeasuredHeight(); int height = getMeasuredHeight();
if (maxWidth - messageTextView.lastLineWidth < timeMore) { 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 { } else {
int diff = maxChildWidth - messageTextView.lastLineWidth; int diff = maxChildWidth - messageTextView.lastLineWidth;
if (diff >= 0 && diff <= timeMore) { 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(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)avatarImage.getLayoutParams();
params.width = height; params.width = height;
params.height = height; params.height = height;
@ -298,22 +298,22 @@ public class NotificationView extends LinearLayout {
if (isLandscape) { if (isLandscape) {
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
nameTextView.setPadding(0, (int)(2 * density), 0, 0); nameTextView.setPadding(0, Utilities.dp(2), 0, 0);
messageTextView.setPadding(0, (int)(18 * density), 0, 0); messageTextView.setPadding(0, Utilities.dp(18), 0, 0);
if (isRTL) { 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 { } else {
params1.setMargins((int)(height + 6 * density), 0, (int)(40 * density), 0); params1.setMargins(height + Utilities.dp(6), 0, Utilities.dp(40), 0);
} }
} else { } else {
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
nameTextView.setPadding(0, (int)(4 * density), 0, 0); nameTextView.setPadding(0, Utilities.dp(4), 0, 0);
messageTextView.setPadding(0, (int) (24 * density), 0, 0); messageTextView.setPadding(0, Utilities.dp(24), 0, 0);
if (isRTL) { 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 { } 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); textLayout.setLayoutParams(params1);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 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