Commit 1add1117 authored by DrKLO's avatar DrKLO

Messages search (not finished)

parent 6c4c5cf3
...@@ -346,7 +346,13 @@ public class Emoji { ...@@ -346,7 +346,13 @@ public class Emoji {
canvas.drawRect(getBounds(), placeholderPaint); canvas.drawRect(getBounds(), placeholderPaint);
return; return;
} }
Rect b = getDrawRect(); Rect b;
if (fullSize) {
b = getDrawRect();
} else {
b = getBounds();
}
if (!canvas.quickReject(b.left, b.top, b.right, b.bottom, Canvas.EdgeType.AA)) { if (!canvas.quickReject(b.left, b.top, b.right, b.bottom, Canvas.EdgeType.AA)) {
canvas.drawBitmap(emojiBmp[info.page], info.rect, b, paint); canvas.drawBitmap(emojiBmp[info.page], info.rect, b, paint);
} }
......
...@@ -23,7 +23,6 @@ public class NotificationCenter { ...@@ -23,7 +23,6 @@ public class NotificationCenter {
public static final int messageReceivedByAck = 9; public static final int messageReceivedByAck = 9;
public static final int messageReceivedByServer = 10; public static final int messageReceivedByServer = 10;
public static final int messageSendError = 11; public static final int messageSendError = 11;
public static final int reloadSearchResults = 12;
public static final int contactsDidLoaded = 13; public static final int contactsDidLoaded = 13;
public static final int chatDidCreated = 15; public static final int chatDidCreated = 15;
public static final int chatDidFailCreate = 16; public static final int chatDidFailCreate = 16;
......
...@@ -1064,7 +1064,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1064,7 +1064,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
private void stopVideoService(final String path) { private void stopVideoService(final String path) {
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
AndroidUtilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
...@@ -1110,7 +1110,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1110,7 +1110,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1); MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1);
} }
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false); MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false);
...@@ -1301,7 +1301,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1301,7 +1301,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (res.file instanceof TLRPC.TL_encryptedFile) { if (res.file instanceof TLRPC.TL_encryptedFile) {
processSentMessage(newMsgObj, null, res.file, req, originalPath); processSentMessage(newMsgObj, null, res.file, req, originalPath);
} }
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
if (newMsgObj.action instanceof TLRPC.TL_messageEncryptedAction) { if (newMsgObj.action instanceof TLRPC.TL_messageEncryptedAction) {
......
...@@ -24,11 +24,11 @@ public class BaseContactsSearchAdapter extends BaseFragmentAdapter { ...@@ -24,11 +24,11 @@ public class BaseContactsSearchAdapter extends BaseFragmentAdapter {
protected String lastFoundUsername = null; protected String lastFoundUsername = null;
public void queryServerSearch(final String query) { public void queryServerSearch(final String query) {
if (reqId != 0) {
ConnectionsManager.getInstance().cancelRpc(reqId, true);
reqId = 0;
}
if (query == null || query.length() < 5) { if (query == null || query.length() < 5) {
if (reqId != 0) {
ConnectionsManager.getInstance().cancelRpc(reqId, true);
reqId = 0;
}
globalSearch.clear(); globalSearch.clear();
lastReqId = 0; lastReqId = 0;
notifyDataSetChanged(); notifyDataSetChanged();
......
...@@ -45,6 +45,13 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter { ...@@ -45,6 +45,13 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
} }
public void searchDialogs(final String query) { public void searchDialogs(final String query) {
try {
if (searchTimer != null) {
searchTimer.cancel();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (query == null) { if (query == null) {
searchResult.clear(); searchResult.clear();
searchResultNames.clear(); searchResultNames.clear();
...@@ -53,13 +60,6 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter { ...@@ -53,13 +60,6 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
} }
notifyDataSetChanged(); notifyDataSetChanged();
} else { } else {
try {
if (searchTimer != null) {
searchTimer.cancel();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
searchTimer = new Timer(); searchTimer = new Timer();
searchTimer.schedule(new TimerTask() { searchTimer.schedule(new TimerTask() {
@Override @Override
......
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.Cells.DialogCell;
public class MessagesActivityAdapter extends BaseFragmentAdapter {
private Context mContext;
private boolean serverOnly;
private long openedDialogId;
public MessagesActivityAdapter(Context context, boolean onlyFromServer) {
mContext = context;
serverOnly = onlyFromServer;
}
public void setOpenedDialogId(long id) {
openedDialogId = id;
}
@Override
public boolean areAllItemsEnabled() {
return true;
}
@Override
public boolean isEnabled(int i) {
return true;
}
@Override
public int getCount() {
int count;
if (serverOnly) {
count = MessagesController.getInstance().dialogsServerOnly.size();
} else {
count = MessagesController.getInstance().dialogs.size();
}
if (count == 0 && MessagesController.getInstance().loadingDialogs) {
return 0;
}
if (!MessagesController.getInstance().dialogsEndReached) {
count++;
}
return count;
}
@Override
public TLRPC.TL_dialog getItem(int i) {
if (serverOnly) {
if (i < 0 || i >= MessagesController.getInstance().dialogsServerOnly.size()) {
return null;
}
return MessagesController.getInstance().dialogsServerOnly.get(i);
} else {
if (i < 0 || i >= MessagesController.getInstance().dialogs.size()) {
return null;
}
return MessagesController.getInstance().dialogs.get(i);
}
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i);
if (type == 1) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.loading_more_layout, viewGroup, false);
}
} else if (type == 0) {
if (view == null) {
view = new DialogCell(mContext);
}
((DialogCell) view).useSeparator = (i != getCount() - 1);
TLRPC.TL_dialog dialog = null;
if (serverOnly) {
dialog = MessagesController.getInstance().dialogsServerOnly.get(i);
} else {
dialog = MessagesController.getInstance().dialogs.get(i);
if (AndroidUtilities.isTablet()) {
if (dialog.id == openedDialogId) {
view.setBackgroundColor(0x0f000000);
} else {
view.setBackgroundColor(0);
}
}
}
MessageObject message = MessagesController.getInstance().dialogMessage.get(dialog.top_message);
((DialogCell) view).setDialog(dialog.id, message, true, dialog.last_message_date, dialog.unread_count);
}
return view;
}
@Override
public int getItemViewType(int i) {
if (serverOnly && i == MessagesController.getInstance().dialogsServerOnly.size() || !serverOnly && i == MessagesController.getInstance().dialogs.size()) {
return 1;
}
return 0;
}
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public boolean isEmpty() {
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
return false;
}
int count;
if (serverOnly) {
count = MessagesController.getInstance().dialogsServerOnly.size();
} else {
count = MessagesController.getInstance().dialogs.size();
}
if (count == 0 && MessagesController.getInstance().loadingDialogs) {
return true;
}
if (!MessagesController.getInstance().dialogsEndReached) {
count++;
}
return count == 0;
}
}
...@@ -21,6 +21,7 @@ import android.text.TextUtils; ...@@ -21,6 +21,7 @@ import android.text.TextUtils;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
...@@ -28,7 +29,6 @@ import org.telegram.android.Emoji; ...@@ -28,7 +29,6 @@ import org.telegram.android.Emoji;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
public class DialogCell extends BaseCell { public class DialogCell extends BaseCell {
...@@ -51,7 +51,12 @@ public class DialogCell extends BaseCell { ...@@ -51,7 +51,12 @@ public class DialogCell extends BaseCell {
private static Paint linePaint; private static Paint linePaint;
private TLRPC.TL_dialog currentDialog; private long currentDialogId;
private boolean allowPrintStrings;
private int lastMessageDate;
private int unreadCount;
private MessageObject message;
private ImageReceiver avatarImage; private ImageReceiver avatarImage;
private DialogCellLayout cellLayout; private DialogCellLayout cellLayout;
...@@ -159,13 +164,17 @@ public class DialogCell extends BaseCell { ...@@ -159,13 +164,17 @@ public class DialogCell extends BaseCell {
init(); init();
} }
public void setDialog(TLRPC.TL_dialog dialog) { public void setDialog(long dialog_id, MessageObject messageObject, boolean usePrintStrings, int date, int unread) {
currentDialog = dialog; currentDialogId = dialog_id;
message = messageObject;
allowPrintStrings = usePrintStrings;
lastMessageDate = date;
unreadCount = unread;
update(0); update(0);
} }
public TLRPC.TL_dialog getDialog() { public long getDialogId() {
return currentDialog; return currentDialogId;
} }
@Override @Override
...@@ -183,7 +192,7 @@ public class DialogCell extends BaseCell { ...@@ -183,7 +192,7 @@ public class DialogCell extends BaseCell {
@Override @Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (currentDialog == null) { if (currentDialogId == 0) {
super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom);
return; return;
} }
...@@ -199,8 +208,8 @@ public class DialogCell extends BaseCell { ...@@ -199,8 +208,8 @@ public class DialogCell extends BaseCell {
public void update(int mask) { public void update(int mask) {
if (mask != 0) { if (mask != 0) {
boolean continueUpdate = false; boolean continueUpdate = false;
if ((mask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) { if (allowPrintStrings && (mask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) {
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentDialog.id); CharSequence printString = MessagesController.getInstance().printingStrings.get(currentDialogId);
if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) { if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) {
continueUpdate = true; continueUpdate = true;
} }
...@@ -237,8 +246,8 @@ public class DialogCell extends BaseCell { ...@@ -237,8 +246,8 @@ public class DialogCell extends BaseCell {
chat = null; chat = null;
encryptedChat = null; encryptedChat = null;
int lower_id = (int)currentDialog.id; int lower_id = (int)currentDialogId;
int high_id = (int)(currentDialog.id >> 32); int high_id = (int)(currentDialogId >> 32);
if (lower_id != 0) { if (lower_id != 0) {
if (high_id == 1) { if (high_id == 1) {
chat = MessagesController.getInstance().getChat(lower_id); chat = MessagesController.getInstance().getChat(lower_id);
...@@ -286,7 +295,7 @@ public class DialogCell extends BaseCell { ...@@ -286,7 +295,7 @@ public class DialogCell extends BaseCell {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
if (currentDialog == null) { if (currentDialogId == 0) {
return; return;
} }
...@@ -404,12 +413,14 @@ public class DialogCell extends BaseCell { ...@@ -404,12 +413,14 @@ public class DialogCell extends BaseCell {
private int avatarLeft; private int avatarLeft;
public void build(int width, int height) { public void build(int width, int height) {
MessageObject message = MessagesController.getInstance().dialogMessage.get(currentDialog.top_message);
String nameString = ""; String nameString = "";
String timeString = ""; String timeString = "";
String countString = null; String countString = null;
CharSequence messageString = ""; CharSequence messageString = "";
CharSequence printingString = MessagesController.getInstance().printingStrings.get(currentDialog.id); CharSequence printingString = null;
if (allowPrintStrings) {
printingString = MessagesController.getInstance().printingStrings.get(currentDialogId);
}
TextPaint currentNamePaint = namePaint; TextPaint currentNamePaint = namePaint;
TextPaint currentMessagePaint = messagePaint; TextPaint currentMessagePaint = messagePaint;
boolean checkMessage = true; boolean checkMessage = true;
...@@ -483,8 +494,8 @@ public class DialogCell extends BaseCell { ...@@ -483,8 +494,8 @@ public class DialogCell extends BaseCell {
} }
} }
} }
if (currentDialog.last_message_date != 0) { if (lastMessageDate != 0) {
timeString = LocaleController.stringForMessageListDate(currentDialog.last_message_date); timeString = LocaleController.stringForMessageListDate(lastMessageDate);
} }
drawCheck1 = false; drawCheck1 = false;
drawCheck2 = false; drawCheck2 = false;
...@@ -494,8 +505,8 @@ public class DialogCell extends BaseCell { ...@@ -494,8 +505,8 @@ public class DialogCell extends BaseCell {
} else { } else {
TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id); TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id);
if (currentDialog.last_message_date != 0) { if (lastMessageDate != 0) {
timeString = LocaleController.stringForMessageListDate(currentDialog.last_message_date); timeString = LocaleController.stringForMessageListDate(lastMessageDate);
} else { } else {
timeString = LocaleController.stringForMessageListDate(message.messageOwner.date); timeString = LocaleController.stringForMessageListDate(message.messageOwner.date);
} }
...@@ -539,9 +550,9 @@ public class DialogCell extends BaseCell { ...@@ -539,9 +550,9 @@ public class DialogCell extends BaseCell {
} }
} }
if (currentDialog.unread_count != 0) { if (unreadCount != 0) {
drawCount = true; drawCount = true;
countString = String.format("%d", currentDialog.unread_count); countString = String.format("%d", unreadCount);
} else { } else {
drawCount = false; drawCount = false;
} }
......
...@@ -88,7 +88,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -88,7 +88,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
currentChat = MessagesController.getInstance().getChat(chat_id); currentChat = MessagesController.getInstance().getChat(chat_id);
if (currentChat == null) { if (currentChat == null) {
final Semaphore semaphore = new Semaphore(0); final Semaphore semaphore = new Semaphore(0);
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
currentChat = MessagesStorage.getInstance().getChat(chat_id); currentChat = MessagesStorage.getInstance().getChat(chat_id);
......
...@@ -14,6 +14,7 @@ import android.content.DialogInterface; ...@@ -14,6 +14,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
import android.view.Gravity; import android.view.Gravity;
...@@ -26,6 +27,7 @@ import android.widget.AbsListView; ...@@ -26,6 +27,7 @@ import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
...@@ -155,11 +157,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -155,11 +157,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
ViewGroup group = (ViewGroup) listView.getParent(); ViewGroup group = (ViewGroup) listView.getParent();
listView.setAdapter(listViewAdapter); listView.setAdapter(listViewAdapter);
listViewAdapter.notifyDataSetChanged(); listViewAdapter.notifyDataSetChanged();
if (!LocaleController.isRTL) { listView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 30 : 16), listView.getPaddingTop(), AndroidUtilities.dp(LocaleController.isRTL ? 16 : 30), listView.getPaddingBottom());
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(30), listView.getPaddingBottom());
} else {
listView.setPadding(AndroidUtilities.dp(30), listView.getPaddingTop(), AndroidUtilities.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);
} }
...@@ -206,6 +204,10 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -206,6 +204,10 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView); listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
listView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 30 : 16), listView.getPaddingTop(), AndroidUtilities.dp(LocaleController.isRTL ? 16 : 30), listView.getPaddingBottom());
if (Build.VERSION.SDK_INT >= 11) {
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
}
emptyTextView.setOnTouchListener(new View.OnTouchListener() { emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
......
...@@ -82,7 +82,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati ...@@ -82,7 +82,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
if (!usersToLoad.isEmpty()) { if (!usersToLoad.isEmpty()) {
final Semaphore semaphore = new Semaphore(0); final Semaphore semaphore = new Semaphore(0);
final ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>(); final ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
users.addAll(MessagesStorage.getInstance().getUsers(usersToLoad)); users.addAll(MessagesStorage.getInstance().getUsers(usersToLoad));
......
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R;
public class SlidingTabView extends LinearLayout {
public static interface SlidingTabViewDelegate {
public abstract void didSelectTab(int tab);
}
private SlidingTabViewDelegate delegate;
private int selectedTab = 0;
private int tabCount = 0;
private float tabWidth = 0;
private float tabX = 0;
private float animateTabXTo = 0;
private Paint paint = new Paint();
private long startAnimationTime = 0;
private long totalAnimationDiff = 0;
private float startAnimationX = 0;
private DecelerateInterpolator interpolator;
private void init() {
setBackgroundResource(R.color.header);
setOrientation(HORIZONTAL);
setWeightSum(100);
interpolator = new DecelerateInterpolator();
}
public SlidingTabView(Context context) {
super(context);
init();
}
public SlidingTabView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public SlidingTabView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public SlidingTabView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
public void addTextTab(final int position, String title) {
TextView tab = new TextView(getContext());
tab.setText(title);
tab.setFocusable(true);
tab.setGravity(Gravity.CENTER);
tab.setSingleLine();
tab.setTextColor(0xffffffff);
tab.setTextSize(12);
tab.setTypeface(Typeface.DEFAULT_BOLD);
tab.setBackgroundResource(R.drawable.bar_selector);
tab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
didSelectTab(position);
}
});
addView(tab);
LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams();
layoutParams.height = LayoutParams.MATCH_PARENT;
layoutParams.width = 0;
layoutParams.weight = 50;
tab.setLayoutParams(layoutParams);
tabCount++;
}
public void setDelegate(SlidingTabViewDelegate delegate) {
this.delegate = delegate;
}
public int getSeletedTab() {
return selectedTab;
}
private void didSelectTab(int tab) {
if (selectedTab == tab) {
return;
}
selectedTab = tab;
animateToTab(tab);
if (delegate != null) {
delegate.didSelectTab(tab);
}
}
private void animateToTab(int tab) {
animateTabXTo = tab * tabWidth;
startAnimationX = tabX;
totalAnimationDiff = 0;
startAnimationTime = System.currentTimeMillis();
invalidate();
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
tabWidth = (r - l) / (float)tabCount;
animateTabXTo = tabX = tabWidth * selectedTab;
}
@Override
protected void onDraw(Canvas canvas) {
paint.setColor(0xaaffffff);
for (int a = 0; a < tabCount - 1; a++) {
canvas.drawRect(tabWidth + a * tabWidth - 1, AndroidUtilities.dp(12), tabWidth + a * tabWidth + 1, getHeight() - AndroidUtilities.dp(12), paint);
}
if (tabX != animateTabXTo) {
long dt = System.currentTimeMillis() - startAnimationTime;
startAnimationTime = System.currentTimeMillis();
totalAnimationDiff += dt;
if (totalAnimationDiff > 200) {
totalAnimationDiff = 200;
tabX = animateTabXTo;
} else {
tabX = startAnimationX + interpolator.getInterpolation(totalAnimationDiff / 200.0f) * (animateTabXTo - startAnimationX);
invalidate();
}
}
canvas.drawRect(tabX, getHeight() - AndroidUtilities.dp(4), (tabX + tabWidth), getHeight(), paint);
}
}
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.telegram.ui.Views.PinnedHeaderListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="30dp"
android:paddingRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"
android:paddingBottom="16dp"
android:fastScrollEnabled="true"
android:fastScrollAlwaysVisible="true"
android:scrollbarStyle="outsideOverlay"
android:layout_gravity="top"
android:verticalScrollbarPosition="left"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="invisible"
android:layout_gravity="top"/>
</FrameLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/messages_list_view"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:clipToPadding="false"
android:fadingEdge="none"
android:divider="@null"
android:dividerHeight="0px"
android:fadingEdgeLength="0dp"
android:verticalScrollbarPosition="left"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="invisible"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/list_empty_view"
android:layout_centerInParent="true"
android:orientation="vertical"
android:gravity="center"
android:visibility="gone">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#959595"
android:textSize="24dp"
android:gravity="center"
android:id="@+id/list_empty_view_text1"/>
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#959595"
android:gravity="center"
android:textSize="15dp"
android:paddingTop="6dp"
android:lineSpacingExtra="2dp"
android:id="@+id/list_empty_view_text2"/>
</LinearLayout>
<LinearLayout
android:id="@+id/progressLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ProgressBar>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"
android:scrollbars="none"
android:paddingBottom="16dp"
android:verticalScrollbarPosition="left"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"/>
<LinearLayout
android:id="@+id/progressLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:clipToPadding="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:dividerHeight="0dp"
android:divider="@null"
android:scrollbars="none"
android:paddingBottom="16dp"
android:verticalScrollbarPosition="left"/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"> android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<org.telegram.ui.Views.SlidingTabView
android:layout_width="match_parent"
android:layout_height="48dp"
android:visibility="gone"
android:id="@+id/searchPanelView"/>
<ListView <ListView
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="match_parent"
android:id="@+id/messages_list_view" android:id="@+id/messages_list_view"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:fadingEdge="none" android:fadingEdge="none"
android:fadingEdgeLength="0dp" android:fadingEdgeLength="0dp"
android:divider="@null" android:divider="@null"
android:dividerHeight="0px" android:dividerHeight="0px"
android:animationCache="false"/> android:animationCache="false"/>
<TextView android:layout_width="match_parent" <TextView
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:textColor="#808080" android:textColor="#808080"
android:gravity="center" android:gravity="center"
android:textSize="24dp" android:textSize="24dp"
android:id="@+id/searchEmptyView" android:id="@+id/searchEmptyView"
android:visibility="invisible"/> android:visibility="gone"/>
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/list_empty_view" android:id="@+id/list_empty_view"
android:layout_centerInParent="true"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center" android:gravity="center"
android:visibility="gone"> android:visibility="gone">
...@@ -40,7 +45,8 @@ ...@@ -40,7 +45,8 @@
android:textSize="24dp" android:textSize="24dp"
android:id="@+id/list_empty_view_text1"/> android:id="@+id/list_empty_view_text1"/>
<TextView android:layout_width="wrap_content" <TextView
android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:textColor="#959595" android:textColor="#959595"
android:gravity="center" android:gravity="center"
...@@ -53,15 +59,17 @@ ...@@ -53,15 +59,17 @@
<LinearLayout <LinearLayout
android:id="@+id/progressLayout" android:id="@+id/progressLayout"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" > android:visibility="gone">
<ProgressBar <ProgressBar
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
</ProgressBar> </ProgressBar>
</LinearLayout> </LinearLayout>
</RelativeLayout>
</LinearLayout>
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">اختر محادثة</string> <string name="SelectChat">اختر محادثة</string>
<string name="PhotoTip">إضغط بإستمرار على المستخدم العرض</string> <string name="PhotoTip">إضغط بإستمرار على المستخدم العرض</string>
<string name="CompatibilityChat">%1$s يستخدم إصدار قديم من تيليجرام، لذلك، الصور السرية ستظهر في وضع الموافقة.\n\nعندما يقوم %2$s بتحديث تيليجرام، الصور التي بها عداد دقيقة أو أقل ستعمل بطريقة \"الاستمرار بالضغط للإستعراض\"، وسيتم إخبارك عندما يلتقط المستقبل صورة من شاشته.</string> <string name="CompatibilityChat">%1$s يستخدم إصدار قديم من تيليجرام، لذلك، الصور السرية ستظهر في وضع الموافقة.\n\nعندما يقوم %2$s بتحديث تيليجرام، الصور التي بها عداد دقيقة أو أقل ستعمل بطريقة \"الاستمرار بالضغط للإستعراض\"، وسيتم إخبارك عندما يلتقط المستقبل صورة من شاشته.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">قائمة الرسالة الجماعية</string> <string name="BroadcastList">قائمة الرسالة الجماعية</string>
<string name="NewBroadcastList">رسالة جماعية جديدة</string> <string name="NewBroadcastList">رسالة جماعية جديدة</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Chat auswählen</string> <string name="SelectChat">Chat auswählen</string>
<string name="PhotoTip">Tippen und Halten</string> <string name="PhotoTip">Tippen und Halten</string>
<string name="CompatibilityChat">%1$s benutzt eine ältere Version von Telegram, sodass Fotos in Geheimen Chats im Kompatibilitätsmodus angezeigt werden.\n\nSobald %2$s Telegram aktualisiert, werden Fotos mit Timern von 1 Minute und kürzer per \"Tippen und Halten\" angezeigt. Du wirst benachrichtigt, sobald dein Chatpartner ein Bildschirmfoto macht.</string> <string name="CompatibilityChat">%1$s benutzt eine ältere Version von Telegram, sodass Fotos in Geheimen Chats im Kompatibilitätsmodus angezeigt werden.\n\nSobald %2$s Telegram aktualisiert, werden Fotos mit Timern von 1 Minute und kürzer per \"Tippen und Halten\" angezeigt. Du wirst benachrichtigt, sobald dein Chatpartner ein Bildschirmfoto macht.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Broadcast Liste</string> <string name="BroadcastList">Broadcast Liste</string>
<string name="NewBroadcastList">Neue Broadcast Liste</string> <string name="NewBroadcastList">Neue Broadcast Liste</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Elige el chat</string> <string name="SelectChat">Elige el chat</string>
<string name="PhotoTip">Mantén pulsado para ver</string> <string name="PhotoTip">Mantén pulsado para ver</string>
<string name="CompatibilityChat">%1$s usa una versión antigua de Telegram, así que las fotos secretas serán mostradas en un modo de compatibilidad.\n\nCuando %2$s actualice Telegram, las fotos con autodestrucción de 1 minuto o menos funcionarán con el modo \'Mantén pulsado para ver\', y te notificaremos siempre que la otra parte haga una captura de pantalla.</string> <string name="CompatibilityChat">%1$s usa una versión antigua de Telegram, así que las fotos secretas serán mostradas en un modo de compatibilidad.\n\nCuando %2$s actualice Telegram, las fotos con autodestrucción de 1 minuto o menos funcionarán con el modo \'Mantén pulsado para ver\', y te notificaremos siempre que la otra parte haga una captura de pantalla.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Lista de difusión</string> <string name="BroadcastList">Lista de difusión</string>
<string name="NewBroadcastList">Nueva difusión</string> <string name="NewBroadcastList">Nueva difusión</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Seleziona chat</string> <string name="SelectChat">Seleziona chat</string>
<string name="PhotoTip">Tieni premuto per vedere</string> <string name="PhotoTip">Tieni premuto per vedere</string>
<string name="CompatibilityChat">%1$s sta usando una versione vecchia di Telegram, quindi le foto segrete verranno visualizzate in modalità di compatibilità.\n\nUna volta che %2$s avrà aggiornato Telegram, le foto con il timer minore di 1 minuto funzioneranno in modalità \'Tieni premuto per vedere\' , e verrai notificato ogni volta che l\'altro esegue uno screenshot.</string> <string name="CompatibilityChat">%1$s sta usando una versione vecchia di Telegram, quindi le foto segrete verranno visualizzate in modalità di compatibilità.\n\nUna volta che %2$s avrà aggiornato Telegram, le foto con il timer minore di 1 minuto funzioneranno in modalità \'Tieni premuto per vedere\' , e verrai notificato ogni volta che l\'altro esegue uno screenshot.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Lista broadcast</string> <string name="BroadcastList">Lista broadcast</string>
<string name="NewBroadcastList">Nuova lista broadcast</string> <string name="NewBroadcastList">Nuova lista broadcast</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">채팅방 선택</string> <string name="SelectChat">채팅방 선택</string>
<string name="PhotoTip">꾹 눌러서 보기</string> <string name="PhotoTip">꾹 눌러서 보기</string>
<string name="CompatibilityChat">%1$s님의 텔레그램 버전이 낮아 비밀 사진을 호환성 모드로 표시합니다.\n\n%2$s님이 텔레그램을 업데이트하고 나면, 자동삭제 시간이 1분 이하인 사진은 \"탭하고 누르고 있어야 보임\" 상태가 되며, 상대방이 화면을 캡처할 때 마다 알림을 받습니다.</string> <string name="CompatibilityChat">%1$s님의 텔레그램 버전이 낮아 비밀 사진을 호환성 모드로 표시합니다.\n\n%2$s님이 텔레그램을 업데이트하고 나면, 자동삭제 시간이 1분 이하인 사진은 \"탭하고 누르고 있어야 보임\" 상태가 되며, 상대방이 화면을 캡처할 때 마다 알림을 받습니다.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">단체 메시지 리스트</string> <string name="BroadcastList">단체 메시지 리스트</string>
<string name="NewBroadcastList">새 단체 메시지 리스트</string> <string name="NewBroadcastList">새 단체 메시지 리스트</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Kies een gesprek</string> <string name="SelectChat">Kies een gesprek</string>
<string name="PhotoTip">Druk en houd ingedrukt</string> <string name="PhotoTip">Druk en houd ingedrukt</string>
<string name="CompatibilityChat">%1$s gebruikt een oudere versie van Telegram, dus worden geheime foto\'s weergegeven in de compatibiliteitsmodus.\n\nZodra %2$s Telegram updatet werken foto\'s met timers voor 1 minuut of minder in de \'Druk en houd ingedrukt\'-modus en krijg je een bericht wanneer de andere partij een schermafbeelding maakt.</string> <string name="CompatibilityChat">%1$s gebruikt een oudere versie van Telegram, dus worden geheime foto\'s weergegeven in de compatibiliteitsmodus.\n\nZodra %2$s Telegram updatet werken foto\'s met timers voor 1 minuut of minder in de \'Druk en houd ingedrukt\'-modus en krijg je een bericht wanneer de andere partij een schermafbeelding maakt.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Verzendlijst</string> <string name="BroadcastList">Verzendlijst</string>
<string name="NewBroadcastList">Nieuwe verzendlijst</string> <string name="NewBroadcastList">Nieuwe verzendlijst</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Selecione uma Conversa</string> <string name="SelectChat">Selecione uma Conversa</string>
<string name="PhotoTip">Toque e segure para ver</string> <string name="PhotoTip">Toque e segure para ver</string>
<string name="CompatibilityChat">%1$s está usando uma versão mais antiga do Telegram, por isso fotos secretas serão mostradas em modo de compatibilidade.\n\nAssim que %2$s atualize o Telegram, fotos com timers de 1 minuto ou menos passarão a funcionar no modo ‘Toque e segure para ver’, e você será notificado caso a outra pessoa salve a tela.</string> <string name="CompatibilityChat">%1$s está usando uma versão mais antiga do Telegram, por isso fotos secretas serão mostradas em modo de compatibilidade.\n\nAssim que %2$s atualize o Telegram, fotos com timers de 1 minuto ou menos passarão a funcionar no modo ‘Toque e segure para ver’, e você será notificado caso a outra pessoa salve a tela.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Lista de Broadcast</string> <string name="BroadcastList">Lista de Broadcast</string>
<string name="NewBroadcastList">Nova Lista de Broadcast</string> <string name="NewBroadcastList">Nova Lista de Broadcast</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Selecione uma Conversa</string> <string name="SelectChat">Selecione uma Conversa</string>
<string name="PhotoTip">Toque e segure para ver</string> <string name="PhotoTip">Toque e segure para ver</string>
<string name="CompatibilityChat">%1$s está usando uma versão mais antiga do Telegram, por isso fotos secretas serão mostradas em modo de compatibilidade.\n\nAssim que %2$s atualize o Telegram, fotos com timers de 1 minuto ou menos passarão a funcionar no modo ‘Toque e segure para ver’, e você será notificado caso a outra pessoa salve a tela.</string> <string name="CompatibilityChat">%1$s está usando uma versão mais antiga do Telegram, por isso fotos secretas serão mostradas em modo de compatibilidade.\n\nAssim que %2$s atualize o Telegram, fotos com timers de 1 minuto ou menos passarão a funcionar no modo ‘Toque e segure para ver’, e você será notificado caso a outra pessoa salve a tela.</string>
<string name="SearchConversations">Conversations</string>
<string name="SearchMessages">Messages</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Lista de Broadcast</string> <string name="BroadcastList">Lista de Broadcast</string>
<string name="NewBroadcastList">Nova Lista de Broadcast</string> <string name="NewBroadcastList">Nova Lista de Broadcast</string>
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
<string name="SelectChat">Select Chat</string> <string name="SelectChat">Select Chat</string>
<string name="PhotoTip">Tap and hold to view</string> <string name="PhotoTip">Tap and hold to view</string>
<string name="CompatibilityChat">%1$s is using an older version of Telegram, so secret photos will be shown in compatibility mode.\n\nOnce %2$s updates Telegram, photos with timers for 1 minute or less will start working in \'Tap and hold to view\' mode, and you will be notified whenever the other party takes a screenshot.</string> <string name="CompatibilityChat">%1$s is using an older version of Telegram, so secret photos will be shown in compatibility mode.\n\nOnce %2$s updates Telegram, photos with timers for 1 minute or less will start working in \'Tap and hold to view\' mode, and you will be notified whenever the other party takes a screenshot.</string>
<string name="SearchConversations">CONVERSATIONS</string>
<string name="SearchMessages">MESSAGES</string>
<!--broadcasts--> <!--broadcasts-->
<string name="BroadcastList">Broadcast List</string> <string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string> <string name="NewBroadcastList">New Broadcast List</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment