More Android L design
@ -43,19 +43,19 @@ android {
|
|||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
debuggable true
|
debuggable true
|
||||||
jniDebugBuild false
|
jniDebuggable true
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
debuggable false
|
debuggable false
|
||||||
jniDebugBuild false
|
jniDebuggable false
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
}
|
}
|
||||||
|
|
||||||
foss {
|
foss {
|
||||||
debuggable false
|
debuggable false
|
||||||
jniDebugBuild false
|
jniDebuggable false
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 21
|
targetSdkVersion 21
|
||||||
versionCode 379
|
versionCode 380
|
||||||
versionName "1.9.7"
|
versionName "2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,11 @@ package org.telegram.android;
|
|||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
import android.content.ContentProviderResult;
|
import android.content.ContentProviderResult;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
@ -35,6 +37,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ContactsController {
|
public class ContactsController {
|
||||||
@ -48,6 +51,8 @@ public class ContactsController {
|
|||||||
private boolean contactsBookLoaded = false;
|
private boolean contactsBookLoaded = false;
|
||||||
private String lastContactsVersions = "";
|
private String lastContactsVersions = "";
|
||||||
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
|
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
|
||||||
|
private String inviteText;
|
||||||
|
private boolean updatingInviteText = false;
|
||||||
|
|
||||||
public static class Contact {
|
public static class Contact {
|
||||||
public int id;
|
public int id;
|
||||||
@ -75,8 +80,7 @@ public class ContactsController {
|
|||||||
|
|
||||||
public HashMap<Integer, Contact> contactsBook = new HashMap<Integer, Contact>();
|
public HashMap<Integer, Contact> contactsBook = new HashMap<Integer, Contact>();
|
||||||
public HashMap<String, Contact> contactsBookSPhones = new HashMap<String, Contact>();
|
public HashMap<String, Contact> contactsBookSPhones = new HashMap<String, Contact>();
|
||||||
public HashMap<String, ArrayList<Contact>> contactsSectionsDict = new HashMap<String, ArrayList<Contact>>();
|
public ArrayList<Contact> phoneBookContacts = new ArrayList<Contact>();
|
||||||
public ArrayList<String> sortedContactsSectionsArray = new ArrayList<String>();
|
|
||||||
|
|
||||||
public ArrayList<TLRPC.TL_contact> contacts = new ArrayList<TLRPC.TL_contact>();
|
public ArrayList<TLRPC.TL_contact> contacts = new ArrayList<TLRPC.TL_contact>();
|
||||||
public SparseArray<TLRPC.TL_contact> contactsDict = new SparseArray<TLRPC.TL_contact>();
|
public SparseArray<TLRPC.TL_contact> contactsDict = new SparseArray<TLRPC.TL_contact>();
|
||||||
@ -102,8 +106,7 @@ public class ContactsController {
|
|||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
contactsBook.clear();
|
contactsBook.clear();
|
||||||
contactsBookSPhones.clear();
|
contactsBookSPhones.clear();
|
||||||
contactsSectionsDict.clear();
|
phoneBookContacts.clear();
|
||||||
sortedContactsSectionsArray.clear();
|
|
||||||
contacts.clear();
|
contacts.clear();
|
||||||
contactsDict.clear();
|
contactsDict.clear();
|
||||||
usersSectionsDict.clear();
|
usersSectionsDict.clear();
|
||||||
@ -118,6 +121,45 @@ public class ContactsController {
|
|||||||
lastContactsVersions = "";
|
lastContactsVersions = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkInviteText() {
|
||||||
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
|
inviteText = preferences.getString("invitetext", null);
|
||||||
|
int time = preferences.getInt("invitetexttime", 0);
|
||||||
|
if (!updatingInviteText && (inviteText == null || time + 86400 < (int)(System.currentTimeMillis() / 1000))) {
|
||||||
|
updatingInviteText = true;
|
||||||
|
TLRPC.TL_help_getInviteText req = new TLRPC.TL_help_getInviteText();
|
||||||
|
req.lang_code = LocaleController.getLocaleString(Locale.getDefault());
|
||||||
|
if (req.lang_code == null || req.lang_code.length() == 0) {
|
||||||
|
req.lang_code = "en";
|
||||||
|
}
|
||||||
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
|
@Override
|
||||||
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
if (error == null) {
|
||||||
|
final TLRPC.TL_help_inviteText res = (TLRPC.TL_help_inviteText)response;
|
||||||
|
if (res.message.length() != 0) {
|
||||||
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updatingInviteText = false;
|
||||||
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
editor.putString("invitetext", res.message);
|
||||||
|
editor.putInt("invitetexttime", (int) (System.currentTimeMillis() / 1000));
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInviteText() {
|
||||||
|
return inviteText != null ? inviteText : LocaleController.getString("InviteText", R.string.InviteText);
|
||||||
|
}
|
||||||
|
|
||||||
public void checkAppAccount() {
|
public void checkAppAccount() {
|
||||||
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
|
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
|
||||||
Account[] accounts = am.getAccountsByType("org.telegram.account");
|
Account[] accounts = am.getAccountsByType("org.telegram.account");
|
||||||
@ -989,8 +1031,7 @@ public class ContactsController {
|
|||||||
contactsPhonesShort.put(user.phone, value);
|
contactsPhonesShort.put(user.phone, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashMap<String, ArrayList<Contact>> sectionsPhoneDict = new HashMap<String, ArrayList<Contact>>();
|
final ArrayList<Contact> sortedPhoneBookContacts = new ArrayList<Contact>();
|
||||||
final ArrayList<String> sortedSectionsPhoneArray = new ArrayList<String>();
|
|
||||||
for (HashMap.Entry<Integer, Contact> pair : contactsBook.entrySet()) {
|
for (HashMap.Entry<Integer, Contact> pair : contactsBook.entrySet()) {
|
||||||
Contact value = pair.getValue();
|
Contact value = pair.getValue();
|
||||||
int id = pair.getKey();
|
int id = pair.getKey();
|
||||||
@ -1007,61 +1048,24 @@ public class ContactsController {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String key = value.first_name;
|
sortedPhoneBookContacts.add(value);
|
||||||
if (key.length() == 0) {
|
|
||||||
key = value.last_name;
|
|
||||||
}
|
|
||||||
if (key.length() == 0) {
|
|
||||||
key = "#";
|
|
||||||
if (value.phones.size() != 0) {
|
|
||||||
value.first_name = "+" + value.phones.get(0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
key = key.toUpperCase();
|
|
||||||
}
|
|
||||||
if (key.length() > 1) {
|
|
||||||
key = key.substring(0, 1);
|
|
||||||
}
|
|
||||||
ArrayList<Contact> arr = sectionsPhoneDict.get(key);
|
|
||||||
if (arr == null) {
|
|
||||||
arr = new ArrayList<Contact>();
|
|
||||||
sectionsPhoneDict.put(key, arr);
|
|
||||||
sortedSectionsPhoneArray.add(key);
|
|
||||||
}
|
|
||||||
arr.add(value);
|
|
||||||
}
|
}
|
||||||
for (HashMap.Entry<String, ArrayList<Contact>> entry : sectionsPhoneDict.entrySet()) {
|
Collections.sort(sortedPhoneBookContacts, new Comparator<Contact>() {
|
||||||
Collections.sort(entry.getValue(), new Comparator<Contact>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Contact contact, Contact contact2) {
|
|
||||||
String toComapre1 = contact.first_name;
|
|
||||||
if (toComapre1.length() == 0) {
|
|
||||||
toComapre1 = contact.last_name;
|
|
||||||
}
|
|
||||||
String toComapre2 = contact2.first_name;
|
|
||||||
if (toComapre2.length() == 0) {
|
|
||||||
toComapre2 = contact2.last_name;
|
|
||||||
}
|
|
||||||
return toComapre1.compareTo(toComapre2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Collections.sort(sortedSectionsPhoneArray, new Comparator<String>() {
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(String s, String s2) {
|
public int compare(Contact contact, Contact contact2) {
|
||||||
char cv1 = s.charAt(0);
|
String toComapre1 = contact.first_name;
|
||||||
char cv2 = s2.charAt(0);
|
if (toComapre1.length() == 0) {
|
||||||
if (cv1 == '#') {
|
toComapre1 = contact.last_name;
|
||||||
return 1;
|
|
||||||
} else if (cv2 == '#') {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
return s.compareTo(s2);
|
String toComapre2 = contact2.first_name;
|
||||||
|
if (toComapre2.length() == 0) {
|
||||||
|
toComapre2 = contact2.last_name;
|
||||||
|
}
|
||||||
|
return toComapre1.compareTo(toComapre2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contactsSectionsDict = sectionsPhoneDict;
|
phoneBookContacts = sortedPhoneBookContacts;
|
||||||
sortedContactsSectionsArray = sortedSectionsPhoneArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildContactsSectionsArrays(boolean sort) {
|
private void buildContactsSectionsArrays(boolean sort) {
|
||||||
|
@ -45,6 +45,7 @@ public class NotificationCenter {
|
|||||||
public static final int wallpapersDidLoaded = 171;
|
public static final int wallpapersDidLoaded = 171;
|
||||||
public static final int closeOtherAppActivities = 702;
|
public static final int closeOtherAppActivities = 702;
|
||||||
public static final int didUpdatedConnectionState = 703;
|
public static final int didUpdatedConnectionState = 703;
|
||||||
|
public static final int didReceiveSmsCode = 998;
|
||||||
public static final int emojiDidLoaded = 999;
|
public static final int emojiDidLoaded = 999;
|
||||||
public static final int appDidLogout = 1234;
|
public static final int appDidLogout = 1234;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class SmsListener extends BroadcastReceiver {
|
|||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
String str = matcher.group(0);
|
String str = matcher.group(0);
|
||||||
if (str.length() >= 3) {
|
if (str.length() >= 3) {
|
||||||
NotificationCenter.getInstance().postNotificationName(998, matcher.group(0));
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, matcher.group(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -640,7 +640,7 @@ public class Utilities {
|
|||||||
builder.append(" ");
|
builder.append(" ");
|
||||||
}
|
}
|
||||||
query.trim();
|
query.trim();
|
||||||
builder.append(Html.fromHtml("<font color=\"#357aa8\">" + query + "</font>"));
|
builder.append(Html.fromHtml("<font color=\"#548ab6\">" + query + "</font>"));
|
||||||
|
|
||||||
lastIndex = end;
|
lastIndex = end;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
* 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.util.SparseArray;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
public abstract class BaseSectionsAdapter extends BaseFragmentAdapter {
|
||||||
|
|
||||||
|
private SparseArray<Integer> sectionPositionCache;
|
||||||
|
private SparseArray<Integer> sectionCache;
|
||||||
|
private SparseArray<Integer> sectionCountCache;
|
||||||
|
private int sectionCount;
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
private void cleanupCache() {
|
||||||
|
sectionCache = new SparseArray<Integer>();
|
||||||
|
sectionPositionCache = new SparseArray<Integer>();
|
||||||
|
sectionCountCache = new SparseArray<Integer>();
|
||||||
|
count = -1;
|
||||||
|
sectionCount = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseSectionsAdapter() {
|
||||||
|
super();
|
||||||
|
cleanupCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
cleanupCache();
|
||||||
|
super.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDataSetInvalidated() {
|
||||||
|
cleanupCache();
|
||||||
|
super.notifyDataSetInvalidated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areAllItemsEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(int position) {
|
||||||
|
return isRowEnabled(getSectionForPosition(position), getPositionInSectionForPosition(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getCount() {
|
||||||
|
if (count >= 0) {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
for (int i = 0; i < internalGetSectionCount(); i++) {
|
||||||
|
count += internalGetCountForSection(i);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Object getItem(int position) {
|
||||||
|
return getItem(getSectionForPosition(position), getPositionInSectionForPosition(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getItemViewType(int position) {
|
||||||
|
return getItemViewType(getSectionForPosition(position), getPositionInSectionForPosition(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
return getItemView(getSectionForPosition(position), getPositionInSectionForPosition(position), convertView, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int internalGetCountForSection(int section) {
|
||||||
|
Integer cachedSectionCount = sectionCountCache.get(section);
|
||||||
|
if (cachedSectionCount != null) {
|
||||||
|
return cachedSectionCount;
|
||||||
|
}
|
||||||
|
int sectionCount = getCountForSection(section);
|
||||||
|
sectionCountCache.put(section, sectionCount);
|
||||||
|
return sectionCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int internalGetSectionCount() {
|
||||||
|
if (sectionCount >= 0) {
|
||||||
|
return sectionCount;
|
||||||
|
}
|
||||||
|
sectionCount = getSectionCount();
|
||||||
|
return sectionCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getSectionForPosition(int position) {
|
||||||
|
Integer cachedSection = sectionCache.get(position);
|
||||||
|
if (cachedSection != null) {
|
||||||
|
return cachedSection;
|
||||||
|
}
|
||||||
|
int sectionStart = 0;
|
||||||
|
for (int i = 0; i < internalGetSectionCount(); i++) {
|
||||||
|
int sectionCount = internalGetCountForSection(i);
|
||||||
|
int sectionEnd = sectionStart + sectionCount;
|
||||||
|
if (position >= sectionStart && position < sectionEnd) {
|
||||||
|
sectionCache.put(position, i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
sectionStart = sectionEnd;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPositionInSectionForPosition(int position) {
|
||||||
|
Integer cachedPosition = sectionPositionCache.get(position);
|
||||||
|
if (cachedPosition != null) {
|
||||||
|
return cachedPosition;
|
||||||
|
}
|
||||||
|
int sectionStart = 0;
|
||||||
|
for (int i = 0; i < internalGetSectionCount(); i++) {
|
||||||
|
int sectionCount = internalGetCountForSection(i);
|
||||||
|
int sectionEnd = sectionStart + sectionCount;
|
||||||
|
if (position >= sectionStart && position < sectionEnd) {
|
||||||
|
int positionInSection = position - sectionStart;
|
||||||
|
sectionPositionCache.put(position, positionInSection);
|
||||||
|
return positionInSection;
|
||||||
|
}
|
||||||
|
sectionStart = sectionEnd;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract int getSectionCount();
|
||||||
|
public abstract int getCountForSection(int section);
|
||||||
|
public abstract boolean isRowEnabled(int section, int row);
|
||||||
|
public abstract int getItemViewType(int section, int position);
|
||||||
|
public abstract Object getItem(int section, int position);
|
||||||
|
public abstract View getItemView(int section, int position, View convertView, ViewGroup parent);
|
||||||
|
public abstract View getSectionHeaderView(int section, View convertView, ViewGroup parent);
|
||||||
|
}
|
@ -9,221 +9,245 @@
|
|||||||
package org.telegram.ui.Adapters;
|
package org.telegram.ui.Adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.android.ContactsController;
|
import org.telegram.android.ContactsController;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.DividerCell;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
import org.telegram.ui.Cells.GreySectionCell;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
import org.telegram.ui.Cells.LetterSectionCell;
|
||||||
|
import org.telegram.ui.Cells.TextCell;
|
||||||
|
import org.telegram.ui.Cells.UserCell;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ContactsActivityAdapter extends SectionedBaseAdapter {
|
public class ContactsActivityAdapter extends BaseSectionsAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean onlyUsers;
|
private boolean onlyUsers;
|
||||||
private boolean usersAsSections;
|
private boolean needPhonebook;
|
||||||
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
||||||
|
|
||||||
public ContactsActivityAdapter(Context context, boolean arg1, boolean arg2, HashMap<Integer, TLRPC.User> arg3) {
|
public ContactsActivityAdapter(Context context, boolean arg1, boolean arg2, HashMap<Integer, TLRPC.User> arg3) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
onlyUsers = arg1;
|
onlyUsers = arg1;
|
||||||
usersAsSections = arg2;
|
needPhonebook = arg2;
|
||||||
ignoreUsers = arg3;
|
ignoreUsers = arg3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int section, int position) {
|
public Object getItem(int section, int position) {
|
||||||
|
if (onlyUsers) {
|
||||||
|
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
||||||
|
return MessagesController.getInstance().getUser(arr.get(position).user_id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if (section == 0) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if (section - 1 < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - 1));
|
||||||
|
if (position < arr.size()) {
|
||||||
|
return MessagesController.getInstance().getUser(arr.get(position).user_id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needPhonebook) {
|
||||||
|
return ContactsController.getInstance().phoneBookContacts.get(position);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int section, int position) {
|
public boolean isRowEnabled(int section, int row) {
|
||||||
return 0;
|
if (onlyUsers) {
|
||||||
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
||||||
|
return row < arr.size();
|
||||||
|
} else {
|
||||||
|
if (section == 0) {
|
||||||
|
if (needPhonebook) {
|
||||||
|
if (row == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (row == 3) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (section - 1 < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - 1));
|
||||||
|
return row < arr.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSectionCount() {
|
public int getSectionCount() {
|
||||||
int count = 0;
|
int count = ContactsController.getInstance().sortedUsersSectionsArray.size();
|
||||||
if (usersAsSections) {
|
if (!onlyUsers) {
|
||||||
count += ContactsController.getInstance().sortedUsersSectionsArray.size();
|
|
||||||
} else {
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (!onlyUsers) {
|
if (needPhonebook) {
|
||||||
count += ContactsController.getInstance().sortedContactsSectionsArray.size();
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCountForSection(int section) {
|
public int getCountForSection(int section) {
|
||||||
if (usersAsSections) {
|
if (onlyUsers) {
|
||||||
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
||||||
return arr.size();
|
int count = arr.size();
|
||||||
|
if (section != (ContactsController.getInstance().sortedUsersSectionsArray.size() - 1) || needPhonebook) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (section == 0) {
|
if (section == 0) {
|
||||||
return ContactsController.getInstance().contacts.size() + 1;
|
if (needPhonebook) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
} else if (section - 1 < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - 1));
|
||||||
|
int count = arr.size();
|
||||||
|
if (section - 1 != (ContactsController.getInstance().sortedUsersSectionsArray.size() - 1) || needPhonebook) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<ContactsController.Contact> arr = ContactsController.getInstance().contactsSectionsDict.get(ContactsController.getInstance().sortedContactsSectionsArray.get(section - 1));
|
if (needPhonebook) {
|
||||||
return arr.size();
|
return ContactsController.getInstance().phoneBookContacts.size();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new LetterSectionCell(mContext);
|
||||||
|
}
|
||||||
|
if (onlyUsers) {
|
||||||
|
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
((LetterSectionCell) convertView).setLetter(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
||||||
|
} else {
|
||||||
|
((LetterSectionCell) convertView).setLetter("");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (section == 0) {
|
||||||
|
((LetterSectionCell) convertView).setLetter("");
|
||||||
|
} else if (section - 1 < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
((LetterSectionCell) convertView).setLetter(ContactsController.getInstance().sortedUsersSectionsArray.get(section - 1));
|
||||||
|
} else {
|
||||||
|
((LetterSectionCell) convertView).setLetter("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
|
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
|
||||||
|
int type = getItemViewType(section, position);
|
||||||
TLRPC.User user = null;
|
if (type == 4) {
|
||||||
int count = 0;
|
|
||||||
if (usersAsSections) {
|
|
||||||
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
|
||||||
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
|
||||||
user = MessagesController.getInstance().getUser(arr.get(position).user_id);
|
|
||||||
count = arr.size();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (section == 0) {
|
|
||||||
if (position == 0) {
|
|
||||||
if (convertView == null) {
|
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
convertView = li.inflate(R.layout.contacts_invite_row_layout, parent, false);
|
|
||||||
TextView textView = (TextView)convertView.findViewById(R.id.messages_list_row_name);
|
|
||||||
textView.setText(LocaleController.getString("InviteFriends", R.string.InviteFriends));
|
|
||||||
}
|
|
||||||
View divider = convertView.findViewById(R.id.settings_row_divider);
|
|
||||||
if (ContactsController.getInstance().contacts.isEmpty()) {
|
|
||||||
divider.setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
user = MessagesController.getInstance().getUser(ContactsController.getInstance().contacts.get(position - 1).user_id);
|
|
||||||
count = ContactsController.getInstance().contacts.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (user != null) {
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = new ChatOrUserCell(mContext);
|
convertView = new DividerCell(mContext);
|
||||||
((ChatOrUserCell)convertView).usePadding = false;
|
convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 24 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 24), 0);
|
||||||
|
}
|
||||||
|
} else if (type == 3) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new GreySectionCell(mContext);
|
||||||
|
((GreySectionCell) convertView).setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase());
|
||||||
|
}
|
||||||
|
} else if (type == 2) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new TextCell(mContext);
|
||||||
|
}
|
||||||
|
TextCell actionCell = (TextCell) convertView;
|
||||||
|
if (needPhonebook) {
|
||||||
|
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
|
||||||
|
} else {
|
||||||
|
if (position == 0) {
|
||||||
|
actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
|
||||||
|
} else if (position == 1) {
|
||||||
|
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
|
||||||
|
} else if (position == 2) {
|
||||||
|
actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new TextCell(mContext);
|
||||||
|
}
|
||||||
|
ContactsController.Contact contact = ContactsController.getInstance().phoneBookContacts.get(position);
|
||||||
|
if (contact.first_name != null && contact.last_name != null) {
|
||||||
|
((TextCell) convertView).setText(contact.first_name + " " + contact.last_name);
|
||||||
|
} else if (contact.first_name != null && contact.last_name == null) {
|
||||||
|
((TextCell) convertView).setText(contact.first_name);
|
||||||
|
} else {
|
||||||
|
((TextCell) convertView).setText(contact.last_name);
|
||||||
|
}
|
||||||
|
} else if (type == 0) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new UserCell(mContext);
|
||||||
|
convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 16 : 54), 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell)convertView).setData(user, null, null, null, null);
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1)));
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id);
|
||||||
|
((UserCell)convertView).setData(user, null, null);
|
||||||
if (ignoreUsers != null) {
|
if (ignoreUsers != null) {
|
||||||
if (ignoreUsers.containsKey(user.id)) {
|
if (ignoreUsers.containsKey(user.id)) {
|
||||||
((ChatOrUserCell)convertView).drawAlpha = 0.5f;
|
((UserCell)convertView).drawAlpha = 0.5f;
|
||||||
} else {
|
} else {
|
||||||
((ChatOrUserCell)convertView).drawAlpha = 1.0f;
|
((UserCell)convertView).drawAlpha = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell) convertView).useSeparator = position != count - 1;
|
|
||||||
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView textView;
|
|
||||||
if (convertView == null) {
|
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
convertView = li.inflate(R.layout.settings_row_button_layout, parent, false);
|
|
||||||
textView = (TextView)convertView.findViewById(R.id.settings_row_text);
|
|
||||||
} else {
|
|
||||||
textView = (TextView)convertView.findViewById(R.id.settings_row_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
View divider = convertView.findViewById(R.id.settings_row_divider);
|
|
||||||
ArrayList<ContactsController.Contact> arr = ContactsController.getInstance().contactsSectionsDict.get(ContactsController.getInstance().sortedContactsSectionsArray.get(section - 1));
|
|
||||||
ContactsController.Contact contact = arr.get(position);
|
|
||||||
if (divider != null) {
|
|
||||||
if (position == arr.size() - 1) {
|
|
||||||
divider.setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (contact.first_name != null && contact.last_name != null) {
|
|
||||||
textView.setText(contact.first_name + " " + contact.last_name);
|
|
||||||
} else if (contact.first_name != null && contact.last_name == null) {
|
|
||||||
textView.setText(contact.first_name);
|
|
||||||
} else {
|
|
||||||
textView.setText(contact.last_name);
|
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int section, int position) {
|
public int getItemViewType(int section, int position) {
|
||||||
if (usersAsSections) {
|
if (onlyUsers) {
|
||||||
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
||||||
return 0;
|
return position < arr.size() ? 0 : 4;
|
||||||
}
|
|
||||||
} else if (section == 0) {
|
|
||||||
if (position == 0) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewTypeCount() {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionHeaderViewType(int section) {
|
|
||||||
if (usersAsSections) {
|
|
||||||
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else if (section == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionHeaderViewTypeCount() {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
|
|
||||||
if (usersAsSections) {
|
|
||||||
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = new SettingsSectionLayout(mContext);
|
|
||||||
convertView.setBackgroundColor(0xffffffff);
|
|
||||||
}
|
|
||||||
((SettingsSectionLayout) convertView).setText(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (section == 0) {
|
if (section == 0) {
|
||||||
if (convertView == null) {
|
if (needPhonebook) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
if (position == 1) {
|
||||||
convertView = li.inflate(R.layout.empty_layout, parent, false);
|
return 3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (position == 3) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return convertView;
|
return 2;
|
||||||
|
} else if (section - 1 < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
||||||
|
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - 1));
|
||||||
|
return position < arr.size() ? 0 : 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (convertView == null) {
|
@Override
|
||||||
convertView = new SettingsSectionLayout(mContext);
|
public int getViewTypeCount() {
|
||||||
convertView.setBackgroundColor(0xffffffff);
|
return 5;
|
||||||
}
|
|
||||||
((SettingsSectionLayout) convertView).setText(ContactsController.getInstance().sortedContactsSectionsArray.get(section - 1));
|
|
||||||
return convertView;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ import org.telegram.messenger.FileLog;
|
|||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.GreySectionCell;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
import org.telegram.ui.Cells.ProfileSearchCell;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -197,16 +197,15 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
if (i == searchResult.size()) {
|
if (i == searchResult.size()) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new SettingsSectionLayout(mContext);
|
view = new GreySectionCell(mContext);
|
||||||
((SettingsSectionLayout) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
((GreySectionCell) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new ChatOrUserCell(mContext);
|
view = new ProfileSearchCell(mContext);
|
||||||
((ChatOrUserCell) view).usePadding = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
|
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
|
||||||
TLRPC.User user = getItem(i);
|
TLRPC.User user = getItem(i);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
CharSequence username = null;
|
CharSequence username = null;
|
||||||
@ -221,20 +220,20 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
}
|
}
|
||||||
} else if (i > searchResult.size() && user.username != null) {
|
} else if (i > searchResult.size() && user.username != null) {
|
||||||
try {
|
try {
|
||||||
username = Html.fromHtml(String.format("<font color=\"#357aa8\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
username = Html.fromHtml(String.format("<font color=\"#548ab6\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
username = user.username;
|
username = user.username;
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell) view).setData(user, null, null, name, username);
|
((ProfileSearchCell) view).setData(user, null, null, name, username);
|
||||||
|
|
||||||
if (ignoreUsers != null) {
|
if (ignoreUsers != null) {
|
||||||
if (ignoreUsers.containsKey(user.id)) {
|
if (ignoreUsers.containsKey(user.id)) {
|
||||||
((ChatOrUserCell) view).drawAlpha = 0.5f;
|
((ProfileSearchCell) view).drawAlpha = 0.5f;
|
||||||
} else {
|
} else {
|
||||||
((ChatOrUserCell) view).drawAlpha = 1.0f;
|
((ProfileSearchCell) view).drawAlpha = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ 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.ui.Cells.DrawerActionCell;
|
import org.telegram.ui.Cells.DrawerActionCell;
|
||||||
import org.telegram.ui.Cells.DrawerDividerCell;
|
import org.telegram.ui.Cells.DividerCell;
|
||||||
import org.telegram.ui.Cells.DrawerEmptyCell;
|
import org.telegram.ui.Cells.EmptyCell;
|
||||||
import org.telegram.ui.Cells.DrawerProfileCell;
|
import org.telegram.ui.Cells.DrawerProfileCell;
|
||||||
|
|
||||||
public class DrawerLayoutAdapter extends BaseAdapter {
|
public class DrawerLayoutAdapter extends BaseAdapter {
|
||||||
@ -37,12 +37,12 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled(int i) {
|
public boolean isEnabled(int i) {
|
||||||
return !(i == 0 || i == 1 || i == 5 || i == 6 || i == 7);
|
return !(i == 0 || i == 1 || i == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return UserConfig.isClientActivated() ? 12 : 0;
|
return UserConfig.isClientActivated() ? 10 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,11 +70,11 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
|||||||
((DrawerProfileCell) view).setUser(MessagesController.getInstance().getUser(UserConfig.getClientUserId()));
|
((DrawerProfileCell) view).setUser(MessagesController.getInstance().getUser(UserConfig.getClientUserId()));
|
||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new DrawerEmptyCell(mContext);
|
view = new EmptyCell(mContext, 8);
|
||||||
}
|
}
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new DrawerDividerCell(mContext);
|
view = new DividerCell(mContext);
|
||||||
}
|
}
|
||||||
} else if (type == 3) {
|
} else if (type == 3) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
@ -87,13 +87,13 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
|||||||
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
|
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
|
||||||
} else if (i == 4) {
|
} else if (i == 4) {
|
||||||
actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
|
actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
|
||||||
} else if (i == 8) {
|
} else if (i == 6) {
|
||||||
actionCell.setTextAndIcon(LocaleController.getString("Contacts", R.string.Contacts), R.drawable.menu_contacts);
|
actionCell.setTextAndIcon(LocaleController.getString("Contacts", R.string.Contacts), R.drawable.menu_contacts);
|
||||||
} else if (i == 9) {
|
} else if (i == 7) {
|
||||||
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
|
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
|
||||||
} else if (i == 10) {
|
} else if (i == 8) {
|
||||||
actionCell.setTextAndIcon(LocaleController.getString("Settings", R.string.Settings), R.drawable.menu_settings);
|
actionCell.setTextAndIcon(LocaleController.getString("Settings", R.string.Settings), R.drawable.menu_settings);
|
||||||
} else if (i == 11) {
|
} else if (i == 9) {
|
||||||
actionCell.setTextAndIcon(LocaleController.getString("TelegramFaq", R.string.TelegramFaq), R.drawable.menu_help);
|
actionCell.setTextAndIcon(LocaleController.getString("TelegramFaq", R.string.TelegramFaq), R.drawable.menu_help);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,9 +105,9 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
|||||||
public int getItemViewType(int i) {
|
public int getItemViewType(int i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (i == 1 || i == 5 || i == 7) {
|
} else if (i == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (i == 6) {
|
} else if (i == 5) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -30,9 +30,9 @@ import org.telegram.messenger.TLObject;
|
|||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
|
||||||
import org.telegram.ui.Cells.DialogCell;
|
import org.telegram.ui.Cells.DialogCell;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
import org.telegram.ui.Cells.GreySectionCell;
|
||||||
|
import org.telegram.ui.Cells.ProfileSearchCell;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
@ -113,7 +113,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchDialogsInternal(final String query, final boolean needEncrypted) {
|
private void searchDialogsInternal(final String query, final boolean serverOnly) {
|
||||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -162,7 +162,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
}
|
}
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
|
||||||
if (needEncrypted) {
|
if (!serverOnly) {
|
||||||
cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT q.data, u.name, q.user, q.g, q.authkey, q.ttl, u.data, u.status, q.layer, q.seq_in, q.seq_out FROM enc_chats as q INNER JOIN dialogs as d ON (q.uid << 32) = d.did INNER JOIN users as u ON q.user = u.uid");
|
cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT q.data, u.name, q.user, q.g, q.authkey, q.ttl, u.data, u.status, q.layer, q.seq_in, q.seq_out FROM enc_chats as q INNER JOIN dialogs as d ON (q.uid << 32) = d.did INNER JOIN users as u ON q.user = u.uid");
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
String name = cursor.stringValue(1);
|
String name = cursor.stringValue(1);
|
||||||
@ -219,7 +219,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0));
|
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0));
|
||||||
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
|
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
|
||||||
TLRPC.Chat chat = (TLRPC.Chat) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
|
TLRPC.Chat chat = (TLRPC.Chat) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
|
||||||
if (!needEncrypted && chat.id < 0) {
|
if (serverOnly && chat.id < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
resultArrayNames.add(Utilities.generateSearchName(chat.title, null, q));
|
resultArrayNames.add(Utilities.generateSearchName(chat.title, null, q));
|
||||||
@ -367,17 +367,16 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
|
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new SettingsSectionLayout(mContext);
|
view = new GreySectionCell(mContext);
|
||||||
view.setPadding(AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11), 0);
|
|
||||||
}
|
}
|
||||||
if (!globalSearch.isEmpty() && i == searchResult.size()) {
|
if (!globalSearch.isEmpty() && i == searchResult.size()) {
|
||||||
((SettingsSectionLayout) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
((GreySectionCell) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
||||||
} else {
|
} else {
|
||||||
((SettingsSectionLayout) view).setText(LocaleController.getString("SearchMessages", R.string.SearchMessages));
|
((GreySectionCell) view).setText(LocaleController.getString("SearchMessages", R.string.SearchMessages));
|
||||||
}
|
}
|
||||||
} else if (type == 0) {
|
} else if (type == 0) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new ChatOrUserCell(mContext);
|
view = new ProfileSearchCell(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
TLRPC.User user = null;
|
TLRPC.User user = null;
|
||||||
@ -385,9 +384,9 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
TLRPC.EncryptedChat encryptedChat = null;
|
TLRPC.EncryptedChat encryptedChat = null;
|
||||||
|
|
||||||
int localCount = searchResult.size();
|
int localCount = searchResult.size();
|
||||||
int globalCount = globalSearch.isEmpty() ? -1 : globalSearch.size() + 1;
|
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1;
|
||||||
|
|
||||||
((ChatOrUserCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1);
|
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1);
|
||||||
Object obj = getItem(i);
|
Object obj = getItem(i);
|
||||||
if (obj instanceof TLRPC.User) {
|
if (obj instanceof TLRPC.User) {
|
||||||
user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
|
user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
|
||||||
@ -413,14 +412,14 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||||||
}
|
}
|
||||||
} else if (i > searchResult.size() && user != null && user.username != null) {
|
} else if (i > searchResult.size() && user != null && user.username != null) {
|
||||||
try {
|
try {
|
||||||
username = Html.fromHtml(String.format("<font color=\"#357aa8\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
username = Html.fromHtml(String.format("<font color=\"#548ab6\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
username = user.username;
|
username = user.username;
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell) view).setData(user, chat, encryptedChat, name, username);
|
((ProfileSearchCell) view).setData(user, chat, encryptedChat, name, username);
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new DialogCell(mContext);
|
view = new DialogCell(mContext);
|
||||||
|
@ -70,7 +70,6 @@ public class DialogCell extends BaseCell {
|
|||||||
|
|
||||||
|
|
||||||
private int nameLeft;
|
private int nameLeft;
|
||||||
private int nameTop = AndroidUtilities.dp(13);
|
|
||||||
private StaticLayout nameLayout;
|
private StaticLayout nameLayout;
|
||||||
private boolean drawNameLock;
|
private boolean drawNameLock;
|
||||||
private boolean drawNameGroup;
|
private boolean drawNameGroup;
|
||||||
@ -142,13 +141,13 @@ public class DialogCell extends BaseCell {
|
|||||||
countPaint.setColor(0xffffffff);
|
countPaint.setColor(0xffffffff);
|
||||||
countPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
countPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
|
||||||
lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green);
|
lockDrawable = getResources().getDrawable(R.drawable.list_secret);
|
||||||
checkDrawable = getResources().getDrawable(R.drawable.dialogs_check);
|
checkDrawable = getResources().getDrawable(R.drawable.dialogs_check);
|
||||||
halfCheckDrawable = getResources().getDrawable(R.drawable.dialogs_halfcheck);
|
halfCheckDrawable = getResources().getDrawable(R.drawable.dialogs_halfcheck);
|
||||||
clockDrawable = getResources().getDrawable(R.drawable.msg_clock);
|
clockDrawable = getResources().getDrawable(R.drawable.msg_clock);
|
||||||
errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning);
|
errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning);
|
||||||
countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
|
countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
|
||||||
groupDrawable = getResources().getDrawable(R.drawable.grouplist);
|
groupDrawable = getResources().getDrawable(R.drawable.list_group);
|
||||||
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
|
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,7 +216,7 @@ public class DialogCell extends BaseCell {
|
|||||||
|
|
||||||
if (encryptedChat != null) {
|
if (encryptedChat != null) {
|
||||||
drawNameLock = true;
|
drawNameLock = true;
|
||||||
nameLockTop = AndroidUtilities.dp(15);
|
nameLockTop = AndroidUtilities.dp(16.5f);
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
nameLockLeft = AndroidUtilities.dp(72);
|
nameLockLeft = AndroidUtilities.dp(72);
|
||||||
nameLeft = AndroidUtilities.dp(76) + lockDrawable.getIntrinsicWidth();
|
nameLeft = AndroidUtilities.dp(76) + lockDrawable.getIntrinsicWidth();
|
||||||
@ -229,10 +228,12 @@ public class DialogCell extends BaseCell {
|
|||||||
if (chat != null) {
|
if (chat != null) {
|
||||||
if (chat.id < 0) {
|
if (chat.id < 0) {
|
||||||
drawNameBroadcast = true;
|
drawNameBroadcast = true;
|
||||||
|
nameLockTop = AndroidUtilities.dp(16.5f);
|
||||||
} else {
|
} else {
|
||||||
drawNameGroup = true;
|
drawNameGroup = true;
|
||||||
|
nameLockTop = AndroidUtilities.dp(17.5f);
|
||||||
}
|
}
|
||||||
nameLockTop = AndroidUtilities.dp(16);
|
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
nameLockLeft = AndroidUtilities.dp(72);
|
nameLockLeft = AndroidUtilities.dp(72);
|
||||||
nameLeft = AndroidUtilities.dp(76) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
nameLeft = AndroidUtilities.dp(76) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
||||||
@ -655,7 +656,7 @@ public class DialogCell extends BaseCell {
|
|||||||
|
|
||||||
if (nameLayout != null) {
|
if (nameLayout != null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(nameLeft, nameTop);
|
canvas.translate(nameLeft, AndroidUtilities.dp(13));
|
||||||
nameLayout.draw(canvas);
|
nameLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
|
||||||
|
public class DividerCell extends BaseCell {
|
||||||
|
|
||||||
|
Paint paint = new Paint();
|
||||||
|
|
||||||
|
public DividerCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
paint.setColor(0xffd9d9d9);
|
||||||
|
paint.setStrokeWidth(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(16) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
canvas.drawLine(getPaddingLeft(), AndroidUtilities.dp(8), getWidth() - getPaddingRight(), AndroidUtilities.dp(8), paint);
|
||||||
|
}
|
||||||
|
}
|
@ -30,13 +30,13 @@ public class DrawerActionCell extends FrameLayout {
|
|||||||
textView.setLines(1);
|
textView.setLines(1);
|
||||||
textView.setMaxLines(1);
|
textView.setMaxLines(1);
|
||||||
textView.setSingleLine(true);
|
textView.setSingleLine(true);
|
||||||
textView.setGravity(Gravity.LEFT | Gravity.CENTER);
|
textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||||
textView.setCompoundDrawablePadding(AndroidUtilities.dp(34));
|
textView.setCompoundDrawablePadding(AndroidUtilities.dp(34));
|
||||||
addView(textView);
|
addView(textView);
|
||||||
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
|
layoutParams.gravity = Gravity.LEFT;
|
||||||
layoutParams.leftMargin = AndroidUtilities.dp(14);
|
layoutParams.leftMargin = AndroidUtilities.dp(14);
|
||||||
layoutParams.rightMargin = AndroidUtilities.dp(16);
|
layoutParams.rightMargin = AndroidUtilities.dp(16);
|
||||||
textView.setLayoutParams(layoutParams);
|
textView.setLayoutParams(layoutParams);
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* This is the source code of Telegram for Android v. 1.7.x.
|
|
||||||
* It is licensed under GNU GPL v. 2 or later.
|
|
||||||
* You should have received a copy of the license in this archive (see LICENSE).
|
|
||||||
*
|
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.telegram.ui.Cells;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
public class DrawerDividerCell extends FrameLayout {
|
|
||||||
|
|
||||||
public DrawerDividerCell(Context context) {
|
|
||||||
super(context);
|
|
||||||
setBackgroundColor(0xffd9d9d9);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(1, MeasureSpec.EXACTLY));
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,14 +13,17 @@ import android.widget.FrameLayout;
|
|||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
|
||||||
public class DrawerEmptyCell extends FrameLayout {
|
public class EmptyCell extends FrameLayout {
|
||||||
|
|
||||||
public DrawerEmptyCell(Context context) {
|
int cellHeight;
|
||||||
|
|
||||||
|
public EmptyCell(Context context, int height) {
|
||||||
super(context);
|
super(context);
|
||||||
|
cellHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(8), MeasureSpec.EXACTLY));
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(cellHeight), MeasureSpec.EXACTLY));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.android.LocaleController;
|
||||||
|
|
||||||
|
public class GreySectionCell extends FrameLayout {
|
||||||
|
private TextView textView;
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setBackgroundColor(0xfff2f2f2);
|
||||||
|
|
||||||
|
textView = new TextView(getContext());
|
||||||
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||||
|
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
textView.setTextColor(0xff8a8a8a);
|
||||||
|
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||||
|
addView(textView);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(16);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(16);
|
||||||
|
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GreySectionCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GreySectionCell(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GreySectionCell(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GreySectionCell(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(36), MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
textView.setText(text);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
|
||||||
|
public class LetterSectionCell extends FrameLayout {
|
||||||
|
|
||||||
|
private TextView textView;
|
||||||
|
|
||||||
|
public LetterSectionCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
setLayoutParams(new ViewGroup.LayoutParams(AndroidUtilities.dp(54), AndroidUtilities.dp(64)));
|
||||||
|
|
||||||
|
textView = new TextView(getContext());
|
||||||
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 22);
|
||||||
|
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
textView.setTextColor(0xff808080);
|
||||||
|
textView.setGravity(Gravity.CENTER);
|
||||||
|
addView(textView);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLetter(String letter) {
|
||||||
|
textView.setText(letter.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* This is the source code of Telegram for Android v. 1.3.x.
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
* It is licensed under GNU GPL v. 2 or later.
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
* You should have received a copy of the license in this archive (see LICENSE).
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
*
|
*
|
||||||
* Copyright Nikolai Kudashov, 2013.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Cells;
|
package org.telegram.ui.Cells;
|
||||||
@ -17,19 +17,19 @@ import android.text.StaticLayout;
|
|||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
|
||||||
import org.telegram.PhoneFormat.PhoneFormat;
|
import org.telegram.PhoneFormat.PhoneFormat;
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.ContactsController;
|
import org.telegram.android.ContactsController;
|
||||||
import org.telegram.android.LocaleController;
|
|
||||||
import org.telegram.messenger.TLRPC;
|
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
|
||||||
import org.telegram.android.MessagesController;
|
|
||||||
import org.telegram.messenger.R;
|
|
||||||
import org.telegram.messenger.UserConfig;
|
|
||||||
import org.telegram.android.ImageReceiver;
|
import org.telegram.android.ImageReceiver;
|
||||||
|
import org.telegram.android.LocaleController;
|
||||||
|
import org.telegram.android.MessagesController;
|
||||||
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.TLRPC;
|
||||||
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
|
|
||||||
public class ChatOrUserCell extends BaseCell {
|
public class ProfileSearchCell extends BaseCell {
|
||||||
private static TextPaint namePaint;
|
private static TextPaint namePaint;
|
||||||
private static TextPaint nameEncryptedPaint;
|
private static TextPaint nameEncryptedPaint;
|
||||||
private static TextPaint onlinePaint;
|
private static TextPaint onlinePaint;
|
||||||
@ -52,7 +52,6 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
private int lastStatus = 0;
|
private int lastStatus = 0;
|
||||||
private TLRPC.FileLocation lastAvatar = null;
|
private TLRPC.FileLocation lastAvatar = null;
|
||||||
|
|
||||||
public boolean usePadding = true;
|
|
||||||
public boolean useSeparator = false;
|
public boolean useSeparator = false;
|
||||||
public float drawAlpha = 1;
|
public float drawAlpha = 1;
|
||||||
|
|
||||||
@ -66,44 +65,44 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
private int nameLockTop;
|
private int nameLockTop;
|
||||||
|
|
||||||
private int onlineLeft;
|
private int onlineLeft;
|
||||||
private int onlineTop = AndroidUtilities.dp(36);
|
|
||||||
private StaticLayout onlineLayout;
|
private StaticLayout onlineLayout;
|
||||||
|
|
||||||
private int avatarTop = AndroidUtilities.dp(7);
|
public ProfileSearchCell(Context context) {
|
||||||
|
|
||||||
public ChatOrUserCell(Context context) {
|
|
||||||
super(context);
|
super(context);
|
||||||
init();
|
init();
|
||||||
avatarImage = new ImageReceiver(this);
|
avatarImage = new ImageReceiver(this);
|
||||||
|
avatarImage.setRoundRadius(AndroidUtilities.dp(26));
|
||||||
avatarDrawable = new AvatarDrawable();
|
avatarDrawable = new AvatarDrawable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
if (namePaint == null) {
|
if (namePaint == null) {
|
||||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
namePaint.setTextSize(AndroidUtilities.dp(18));
|
namePaint.setTextSize(AndroidUtilities.dp(17));
|
||||||
namePaint.setColor(0xff222222);
|
namePaint.setColor(0xff222222);
|
||||||
|
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
|
||||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(18));
|
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(17));
|
||||||
nameEncryptedPaint.setColor(0xff00a60e);
|
nameEncryptedPaint.setColor(0xff00a60e);
|
||||||
|
nameEncryptedPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
|
||||||
onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
onlinePaint.setTextSize(AndroidUtilities.dp(15));
|
onlinePaint.setTextSize(AndroidUtilities.dp(16));
|
||||||
onlinePaint.setColor(0xff316f9f);
|
onlinePaint.setColor(0xff316f9f);
|
||||||
|
|
||||||
offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
offlinePaint.setTextSize(AndroidUtilities.dp(15));
|
offlinePaint.setTextSize(AndroidUtilities.dp(16));
|
||||||
offlinePaint.setColor(0xff999999);
|
offlinePaint.setColor(0xff999999);
|
||||||
|
|
||||||
lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green);
|
lockDrawable = getResources().getDrawable(R.drawable.list_secret);
|
||||||
|
|
||||||
linePaint = new Paint();
|
linePaint = new Paint();
|
||||||
linePaint.setColor(0xffdcdcdc);
|
linePaint.setColor(0xffdcdcdc);
|
||||||
|
|
||||||
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
|
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
|
||||||
|
|
||||||
groupDrawable = getResources().getDrawable(R.drawable.grouplist);
|
groupDrawable = getResources().getDrawable(R.drawable.list_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +126,7 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(64));
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(72));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -152,33 +151,35 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
if (encryptedChat != null) {
|
if (encryptedChat != null) {
|
||||||
drawNameLock = true;
|
drawNameLock = true;
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
nameLockLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
nameLockLeft = AndroidUtilities.dp(72);
|
||||||
nameLeft = AndroidUtilities.dp(65 + (usePadding ? 11 : 0)) + lockDrawable.getIntrinsicWidth();
|
nameLeft = AndroidUtilities.dp(76) + lockDrawable.getIntrinsicWidth();
|
||||||
} else {
|
} else {
|
||||||
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - lockDrawable.getIntrinsicWidth();
|
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(74) - lockDrawable.getIntrinsicWidth();
|
||||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
nameLeft = AndroidUtilities.dp(11);
|
||||||
}
|
}
|
||||||
nameLockTop = AndroidUtilities.dp(15);
|
nameLockTop = AndroidUtilities.dp(16.5f);
|
||||||
} else {
|
} else {
|
||||||
if (chat != null) {
|
if (chat != null) {
|
||||||
nameLockTop = AndroidUtilities.dp(26);
|
|
||||||
if (chat.id < 0) {
|
if (chat.id < 0) {
|
||||||
drawNameBroadcast = true;
|
drawNameBroadcast = true;
|
||||||
|
nameLockTop = AndroidUtilities.dp(28.5f);
|
||||||
} else {
|
} else {
|
||||||
drawNameGroup = true;
|
drawNameGroup = true;
|
||||||
|
nameLockTop = AndroidUtilities.dp(30);
|
||||||
}
|
}
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
nameLockLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
nameLockLeft = AndroidUtilities.dp(72);
|
||||||
nameLeft = AndroidUtilities.dp(65 + (usePadding ? 11 : 0)) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
nameLeft = AndroidUtilities.dp(76) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
||||||
} else {
|
} else {
|
||||||
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(74) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
||||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
nameLeft = AndroidUtilities.dp(11);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
nameLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
nameLeft = AndroidUtilities.dp(72);
|
||||||
} else {
|
} else {
|
||||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
nameLeft = AndroidUtilities.dp(11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,14 +211,16 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
int onlineWidth;
|
int onlineWidth;
|
||||||
int nameWidth;
|
int nameWidth;
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(3 + (usePadding ? 11 : 0));
|
onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(14);
|
||||||
} else {
|
} else {
|
||||||
onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(72);
|
||||||
}
|
}
|
||||||
if (drawNameLock) {
|
if (drawNameLock) {
|
||||||
nameWidth -= AndroidUtilities.dp(6) + lockDrawable.getIntrinsicWidth();
|
nameWidth -= AndroidUtilities.dp(6) + lockDrawable.getIntrinsicWidth();
|
||||||
} else if (drawNameBroadcast) {
|
} else if (drawNameBroadcast) {
|
||||||
nameWidth -= AndroidUtilities.dp(6) + broadcastDrawable.getIntrinsicWidth();
|
nameWidth -= AndroidUtilities.dp(6) + broadcastDrawable.getIntrinsicWidth();
|
||||||
|
} else if (drawNameGroup) {
|
||||||
|
nameWidth -= AndroidUtilities.dp(6) + groupDrawable.getIntrinsicWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||||
@ -225,9 +228,9 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
|
|
||||||
if (chat == null) {
|
if (chat == null) {
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
onlineLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
onlineLeft = AndroidUtilities.dp(72);
|
||||||
} else {
|
} else {
|
||||||
onlineLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
onlineLeft = AndroidUtilities.dp(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
CharSequence onlineString = "";
|
CharSequence onlineString = "";
|
||||||
@ -243,22 +246,22 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, onlineWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||||
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, onlineWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
nameTop = AndroidUtilities.dp(12);
|
nameTop = AndroidUtilities.dp(13);
|
||||||
} else {
|
} else {
|
||||||
onlineLayout = null;
|
onlineLayout = null;
|
||||||
nameTop = AndroidUtilities.dp(22);
|
nameTop = AndroidUtilities.dp(25);
|
||||||
}
|
}
|
||||||
|
|
||||||
int avatarLeft;
|
int avatarLeft;
|
||||||
if (!LocaleController.isRTL) {
|
if (!LocaleController.isRTL) {
|
||||||
avatarLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
avatarLeft = AndroidUtilities.dp(9);
|
||||||
} else {
|
} else {
|
||||||
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(50 + (usePadding ? 11 : 0));
|
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(61);
|
||||||
}
|
}
|
||||||
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
|
||||||
|
|
||||||
|
avatarImage.setImageCoords(avatarLeft, AndroidUtilities.dp(10), AndroidUtilities.dp(52), AndroidUtilities.dp(52));
|
||||||
|
|
||||||
double widthpx = 0;
|
double widthpx = 0;
|
||||||
float left = 0;
|
float left = 0;
|
||||||
@ -382,11 +385,10 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useSeparator) {
|
if (useSeparator) {
|
||||||
int h = getMeasuredHeight();
|
if (LocaleController.isRTL) {
|
||||||
if (!usePadding) {
|
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(72), getMeasuredHeight() - 1, linePaint);
|
||||||
canvas.drawLine(0, h - 1, getMeasuredWidth(), h - 1, linePaint);
|
|
||||||
} else {
|
} else {
|
||||||
canvas.drawLine(AndroidUtilities.dp(11), h - 1, getMeasuredWidth() - AndroidUtilities.dp(11), h - 1, linePaint);
|
canvas.drawLine(AndroidUtilities.dp(72), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +414,7 @@ public class ChatOrUserCell extends BaseCell {
|
|||||||
|
|
||||||
if (onlineLayout != null) {
|
if (onlineLayout != null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(onlineLeft, onlineTop);
|
canvas.translate(onlineLeft, AndroidUtilities.dp(40));
|
||||||
onlineLayout.draw(canvas);
|
onlineLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
126
TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.android.LocaleController;
|
||||||
|
|
||||||
|
public class TextCell extends FrameLayout {
|
||||||
|
|
||||||
|
private TextView textView;
|
||||||
|
private TextView valueTextView;
|
||||||
|
private ImageView imageView;
|
||||||
|
private ImageView valueImageView;
|
||||||
|
|
||||||
|
public TextCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
|
||||||
|
textView = new TextView(context);
|
||||||
|
textView.setTextColor(0xff000000);
|
||||||
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||||
|
textView.setLines(1);
|
||||||
|
textView.setMaxLines(1);
|
||||||
|
textView.setSingleLine(true);
|
||||||
|
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||||
|
addView(textView);
|
||||||
|
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16);
|
||||||
|
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
valueTextView = new TextView(context);
|
||||||
|
valueTextView.setTextColor(0xff2f8cc9);
|
||||||
|
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||||
|
valueTextView.setLines(1);
|
||||||
|
valueTextView.setMaxLines(1);
|
||||||
|
valueTextView.setSingleLine(true);
|
||||||
|
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
|
||||||
|
addView(valueTextView);
|
||||||
|
layoutParams = (LayoutParams) valueTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
|
||||||
|
layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT;
|
||||||
|
valueTextView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
imageView = new ImageView(context);
|
||||||
|
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
addView(imageView);
|
||||||
|
layoutParams = (LayoutParams) imageView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
|
||||||
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
|
||||||
|
imageView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
valueImageView = new ImageView(context);
|
||||||
|
valueImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
addView(valueImageView);
|
||||||
|
layoutParams = (LayoutParams) valueImageView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
|
||||||
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL;
|
||||||
|
valueImageView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(int color) {
|
||||||
|
textView.setTextColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
textView.setText(text);
|
||||||
|
imageView.setVisibility(GONE);
|
||||||
|
valueTextView.setVisibility(GONE);
|
||||||
|
valueImageView.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextAndIcon(String text, int resId) {
|
||||||
|
textView.setText(text);
|
||||||
|
imageView.setImageResource(resId);
|
||||||
|
imageView.setVisibility(VISIBLE);
|
||||||
|
valueTextView.setVisibility(GONE);
|
||||||
|
valueImageView.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextAndValue(String text, String value) {
|
||||||
|
textView.setText(text);
|
||||||
|
valueTextView.setText(value);
|
||||||
|
valueTextView.setVisibility(VISIBLE);
|
||||||
|
imageView.setVisibility(GONE);
|
||||||
|
valueImageView.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextAndValueDrawable(String text, Drawable drawable) {
|
||||||
|
textView.setText(text);
|
||||||
|
valueImageView.setVisibility(VISIBLE);
|
||||||
|
valueImageView.setImageDrawable(drawable);
|
||||||
|
valueTextView.setVisibility(GONE);
|
||||||
|
imageView.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.android.LocaleController;
|
||||||
|
|
||||||
|
public class TextDetailCell extends FrameLayout {
|
||||||
|
|
||||||
|
private TextView textView;
|
||||||
|
private TextView valueTextView;
|
||||||
|
private ImageView imageView;
|
||||||
|
|
||||||
|
public TextDetailCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
|
||||||
|
textView = new TextView(context);
|
||||||
|
textView.setTextColor(0xff000000);
|
||||||
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||||
|
textView.setLines(1);
|
||||||
|
textView.setMaxLines(1);
|
||||||
|
textView.setSingleLine(true);
|
||||||
|
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||||
|
addView(textView);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(11);
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16);
|
||||||
|
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
valueTextView = new TextView(context);
|
||||||
|
valueTextView.setTextColor(0xff8a8a8a);
|
||||||
|
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||||
|
valueTextView.setLines(1);
|
||||||
|
valueTextView.setMaxLines(1);
|
||||||
|
valueTextView.setSingleLine(true);
|
||||||
|
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
|
||||||
|
addView(valueTextView);
|
||||||
|
layoutParams = (FrameLayout.LayoutParams) valueTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(36);
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16);
|
||||||
|
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
|
||||||
|
valueTextView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
imageView = new ImageView(context);
|
||||||
|
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
addView(imageView);
|
||||||
|
layoutParams = (LayoutParams) imageView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
|
||||||
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
|
||||||
|
imageView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), View.MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextAndValue(String text, String value) {
|
||||||
|
textView.setText(text);
|
||||||
|
valueTextView.setText(value);
|
||||||
|
imageView.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextAndValueAndIcon(String text, String value, int resId) {
|
||||||
|
textView.setText(text);
|
||||||
|
valueTextView.setText(value);
|
||||||
|
imageView.setVisibility(VISIBLE);
|
||||||
|
imageView.setImageResource(resId);
|
||||||
|
}
|
||||||
|
}
|
302
TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.3.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.text.Layout;
|
||||||
|
import android.text.StaticLayout;
|
||||||
|
import android.text.TextPaint;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.PhoneFormat.PhoneFormat;
|
||||||
|
import org.telegram.android.ContactsController;
|
||||||
|
import org.telegram.android.LocaleController;
|
||||||
|
import org.telegram.messenger.TLRPC;
|
||||||
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
|
import org.telegram.android.MessagesController;
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.UserConfig;
|
||||||
|
import org.telegram.android.ImageReceiver;
|
||||||
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
|
|
||||||
|
public class UserCell extends BaseCell {
|
||||||
|
private static TextPaint namePaint;
|
||||||
|
private static TextPaint onlinePaint;
|
||||||
|
private static TextPaint offlinePaint;
|
||||||
|
private static Paint linePaint;
|
||||||
|
|
||||||
|
private CharSequence currentName;
|
||||||
|
private ImageReceiver avatarImage;
|
||||||
|
private AvatarDrawable avatarDrawable;
|
||||||
|
private CharSequence subLabel;
|
||||||
|
|
||||||
|
private TLRPC.User user = null;
|
||||||
|
|
||||||
|
private String lastName = null;
|
||||||
|
private int lastStatus = 0;
|
||||||
|
private TLRPC.FileLocation lastAvatar = null;
|
||||||
|
|
||||||
|
public boolean useSeparator = false;
|
||||||
|
public float drawAlpha = 1;
|
||||||
|
|
||||||
|
private int nameLeft;
|
||||||
|
private int nameTop;
|
||||||
|
private StaticLayout nameLayout;
|
||||||
|
|
||||||
|
private int onlineLeft;
|
||||||
|
private int onlineTop = AndroidUtilities.dp(36);
|
||||||
|
private StaticLayout onlineLayout;
|
||||||
|
|
||||||
|
public UserCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
init();
|
||||||
|
avatarImage = new ImageReceiver(this);
|
||||||
|
avatarImage.setRoundRadius(AndroidUtilities.dp(24));
|
||||||
|
avatarDrawable = new AvatarDrawable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
if (namePaint == null) {
|
||||||
|
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
namePaint.setTextSize(AndroidUtilities.dp(18));
|
||||||
|
namePaint.setColor(0xff222222);
|
||||||
|
|
||||||
|
onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
onlinePaint.setTextSize(AndroidUtilities.dp(15));
|
||||||
|
onlinePaint.setColor(0xff316f9f);
|
||||||
|
|
||||||
|
offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
offlinePaint.setTextSize(AndroidUtilities.dp(15));
|
||||||
|
offlinePaint.setColor(0xff999999);
|
||||||
|
|
||||||
|
linePaint = new Paint();
|
||||||
|
linePaint.setColor(0xffdcdcdc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(TLRPC.User u, CharSequence n, CharSequence s) {
|
||||||
|
currentName = n;
|
||||||
|
user = u;
|
||||||
|
subLabel = s;
|
||||||
|
update(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
if (avatarImage != null) {
|
||||||
|
avatarImage.clearImage();
|
||||||
|
lastAvatar = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec) - getPaddingRight(), AndroidUtilities.dp(64));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
|
if (user == null) {
|
||||||
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (changed) {
|
||||||
|
buildLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildLayout() {
|
||||||
|
int paddingLeft = getPaddingLeft();
|
||||||
|
int paddingRight = getPaddingRight();
|
||||||
|
|
||||||
|
onlineLeft = nameLeft = AndroidUtilities.dp(LocaleController.isRTL ? 11 : 72) + paddingLeft;
|
||||||
|
int avatarLeft = paddingLeft + (LocaleController.isRTL ? (getMeasuredWidth() - AndroidUtilities.dp(61)) : AndroidUtilities.dp(11));
|
||||||
|
int nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(LocaleController.isRTL ? 72 : 14);
|
||||||
|
int avatarTop = AndroidUtilities.dp(8);
|
||||||
|
|
||||||
|
CharSequence nameString = "";
|
||||||
|
if (currentName != null) {
|
||||||
|
nameString = currentName;
|
||||||
|
} else {
|
||||||
|
String nameString2 = "";
|
||||||
|
if (user != null) {
|
||||||
|
nameString2 = ContactsController.formatName(user.first_name, user.last_name);
|
||||||
|
}
|
||||||
|
nameString = nameString2.replace("\n", " ");
|
||||||
|
}
|
||||||
|
if (nameString.length() == 0) {
|
||||||
|
if (user != null && user.phone != null && user.phone.length() != 0) {
|
||||||
|
nameString = PhoneFormat.getInstance().format("+" + user.phone);
|
||||||
|
} else {
|
||||||
|
nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||||
|
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
|
||||||
|
CharSequence onlineString = "";
|
||||||
|
TextPaint currentOnlinePaint = offlinePaint;
|
||||||
|
if (subLabel != null) {
|
||||||
|
onlineString = subLabel;
|
||||||
|
} else {
|
||||||
|
onlineString = LocaleController.formatUserStatus(user);
|
||||||
|
if (user != null && (user.id == UserConfig.getClientUserId() || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
|
||||||
|
currentOnlinePaint = onlinePaint;
|
||||||
|
onlineString = LocaleController.getString("Online", R.string.Online);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||||
|
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
nameTop = AndroidUtilities.dp(12);
|
||||||
|
|
||||||
|
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(48), AndroidUtilities.dp(48));
|
||||||
|
|
||||||
|
double widthpx = 0;
|
||||||
|
float left = 0;
|
||||||
|
if (LocaleController.isRTL) {
|
||||||
|
if (nameLayout.getLineCount() > 0) {
|
||||||
|
left = nameLayout.getLineLeft(0);
|
||||||
|
if (left == 0) {
|
||||||
|
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||||
|
if (widthpx < nameWidth) {
|
||||||
|
nameLeft += (nameWidth - widthpx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
|
||||||
|
left = onlineLayout.getLineLeft(0);
|
||||||
|
if (left == 0) {
|
||||||
|
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
|
||||||
|
if (widthpx < nameWidth) {
|
||||||
|
onlineLeft += (nameWidth - widthpx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (nameLayout.getLineCount() > 0) {
|
||||||
|
left = nameLayout.getLineRight(0);
|
||||||
|
if (left == nameWidth) {
|
||||||
|
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||||
|
if (widthpx < nameWidth) {
|
||||||
|
nameLeft -= (nameWidth - widthpx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
|
||||||
|
left = onlineLayout.getLineRight(0);
|
||||||
|
if (left == nameWidth) {
|
||||||
|
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
|
||||||
|
if (widthpx < nameWidth) {
|
||||||
|
onlineLeft -= (nameWidth - widthpx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(int mask) {
|
||||||
|
TLRPC.FileLocation photo = null;
|
||||||
|
if (user != null) {
|
||||||
|
if (user.photo != null) {
|
||||||
|
photo = user.photo.photo_small;
|
||||||
|
}
|
||||||
|
avatarDrawable.setInfo(user);
|
||||||
|
} else {
|
||||||
|
avatarDrawable.setInfo(0, null, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask != 0) {
|
||||||
|
boolean continueUpdate = false;
|
||||||
|
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 && user != null) {
|
||||||
|
if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
|
||||||
|
continueUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0 && user != null) {
|
||||||
|
int newStatus = 0;
|
||||||
|
if (user.status != null) {
|
||||||
|
newStatus = user.status.expires;
|
||||||
|
}
|
||||||
|
if (newStatus != lastStatus) {
|
||||||
|
continueUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0 && user != null) {
|
||||||
|
String newName = null;
|
||||||
|
if (user != null) {
|
||||||
|
newName = user.first_name + user.last_name;
|
||||||
|
}
|
||||||
|
if (newName == null || !newName.equals(lastName)) {
|
||||||
|
continueUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!continueUpdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user != null) {
|
||||||
|
if (user.status != null) {
|
||||||
|
lastStatus = user.status.expires;
|
||||||
|
} else {
|
||||||
|
lastStatus = 0;
|
||||||
|
}
|
||||||
|
lastName = user.first_name + user.last_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastAvatar = photo;
|
||||||
|
avatarImage.setImage(photo, "50_50", avatarDrawable, false);
|
||||||
|
|
||||||
|
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
|
||||||
|
buildLayout();
|
||||||
|
} else {
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
postInvalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useSeparator) {
|
||||||
|
if (LocaleController.isRTL) {
|
||||||
|
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(72), getMeasuredHeight() - 1, linePaint);
|
||||||
|
} else {
|
||||||
|
canvas.drawLine(AndroidUtilities.dp(72), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawAlpha != 1) {
|
||||||
|
canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int)(255 * drawAlpha), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.save();
|
||||||
|
canvas.translate(nameLeft, nameTop);
|
||||||
|
nameLayout.draw(canvas);
|
||||||
|
canvas.restore();
|
||||||
|
|
||||||
|
if (onlineLayout != null) {
|
||||||
|
canvas.save();
|
||||||
|
canvas.translate(onlineLeft, onlineTop);
|
||||||
|
onlineLayout.draw(canvas);
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarImage.draw(canvas);
|
||||||
|
}
|
||||||
|
}
|
@ -436,7 +436,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
if (currentEncryptedChat != null) {
|
if (currentEncryptedChat != null) {
|
||||||
MediaController.getInstance().stopMediaObserver();
|
MediaController.getInstance().stopMediaObserver();
|
||||||
}
|
}
|
||||||
|
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
AndroidUtilities.unlockOrientation(getParentActivity());
|
AndroidUtilities.unlockOrientation(getParentActivity());
|
||||||
MediaController.getInstance().stopAudio();
|
MediaController.getInstance().stopAudio();
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
if (currentEncryptedChat != null) {
|
if (currentEncryptedChat != null) {
|
||||||
args.putLong("dialog_id", dialog_id);
|
args.putLong("dialog_id", dialog_id);
|
||||||
}
|
}
|
||||||
presentFragment(new UserProfileActivity(args));
|
presentFragment(new ProfileActivity(args));
|
||||||
} else if (currentChat != null) {
|
} else if (currentChat != null) {
|
||||||
if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) {
|
if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) {
|
||||||
return;
|
return;
|
||||||
@ -2383,6 +2383,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
if (parentLayout != null) {
|
||||||
|
parentLayout.getDrawerLayoutContainer().setStatusBarColor(0xff54759e);
|
||||||
|
}
|
||||||
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||||
|
|
||||||
checkActionBarMenu();
|
checkActionBarMenu();
|
||||||
@ -2459,7 +2462,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
||||||
actionBarLayer.hideActionMode();
|
actionBarLayer.hideActionMode();
|
||||||
chatActivityEnterView.hideEmojiPopup();
|
chatActivityEnterView.hideEmojiPopup();
|
||||||
paused = true;
|
paused = true;
|
||||||
@ -3127,7 +3129,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
if (user != null && user.id != UserConfig.getClientUserId()) {
|
if (user != null && user.id != UserConfig.getClientUserId()) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", user.id);
|
args.putInt("user_id", user.id);
|
||||||
presentFragment(new UserProfileActivity(args));
|
presentFragment(new ProfileActivity(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3315,7 +3317,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
if (uid != UserConfig.getClientUserId()) {
|
if (uid != UserConfig.getClientUserId()) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", uid);
|
args.putInt("user_id", uid);
|
||||||
presentFragment(new UserProfileActivity(args));
|
presentFragment(new ProfileActivity(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,7 @@ import org.telegram.messenger.UserConfig;
|
|||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.android.MessageObject;
|
import org.telegram.android.MessageObject;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
@ -257,7 +257,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", user_id);
|
args.putInt("user_id", user_id);
|
||||||
presentFragment(new UserProfileActivity(args));
|
presentFragment(new ProfileActivity(args));
|
||||||
} else if (i == settingsNotificationsRow) {
|
} else if (i == settingsNotificationsRow) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("dialog_id", -chat_id);
|
args.putLong("dialog_id", -chat_id);
|
||||||
@ -403,8 +403,8 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
int count = listView.getChildCount();
|
int count = listView.getChildCount();
|
||||||
for (int a = 0; a < count; a++) {
|
for (int a = 0; a < count; a++) {
|
||||||
View child = listView.getChildAt(a);
|
View child = listView.getChildAt(a);
|
||||||
if (child instanceof ChatOrUserCell) {
|
if (child instanceof UserCell) {
|
||||||
((ChatOrUserCell) child).update(mask);
|
((UserCell) child).update(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,7 +476,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlyUsers", true);
|
args.putBoolean("onlyUsers", true);
|
||||||
args.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
args.putBoolean("usersAsSections", true);
|
|
||||||
args.putBoolean("returnAsResult", true);
|
args.putBoolean("returnAsResult", true);
|
||||||
//args.putBoolean("allowUsernameSearch", false);
|
//args.putBoolean("allowUsernameSearch", false);
|
||||||
if (chat_id > 0) {
|
if (chat_id > 0) {
|
||||||
@ -633,7 +632,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count != 0 && onlineCount > 1) {
|
if (count != 0 && onlineCount > 1) {
|
||||||
onlineText.setText(Html.fromHtml(String.format("%s, <font color='#357aa8'>%s</font>", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))));
|
onlineText.setText(Html.fromHtml(String.format("%s, <font color='#548ab6'>%s</font>", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))));
|
||||||
} else {
|
} else {
|
||||||
onlineText.setText(LocaleController.formatPluralString("Members", count));
|
onlineText.setText(LocaleController.formatPluralString("Members", count));
|
||||||
}
|
}
|
||||||
@ -685,12 +684,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
TLRPC.User user = MessagesController.getInstance().getUser(part.user_id);
|
TLRPC.User user = MessagesController.getInstance().getUser(part.user_id);
|
||||||
|
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new ChatOrUserCell(mContext);
|
view = new UserCell(mContext);
|
||||||
((ChatOrUserCell)view).usePadding = false;
|
((UserCell)view).useSeparator = true;
|
||||||
((ChatOrUserCell)view).useSeparator = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell)view).setData(user, null, null, null, null);
|
((UserCell)view).setData(user, null, null);
|
||||||
} else if (type == 4) {
|
} else if (type == 4) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
@ -8,11 +8,9 @@
|
|||||||
|
|
||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -33,48 +31,43 @@ import android.widget.TextView;
|
|||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.android.MessagesStorage;
|
import org.telegram.android.MessagesStorage;
|
||||||
import org.telegram.messenger.TLObject;
|
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
|
||||||
import org.telegram.android.ContactsController;
|
import org.telegram.android.ContactsController;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.android.NotificationCenter;
|
import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
|
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
import org.telegram.ui.Views.SectionsListView;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class ContactsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class ContactsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
private SectionedBaseAdapter listViewAdapter;
|
|
||||||
private PinnedHeaderListView listView;
|
private BaseSectionsAdapter listViewAdapter;
|
||||||
|
private TextView emptyTextView;
|
||||||
|
private SectionsListView listView;
|
||||||
private ContactsActivitySearchAdapter searchListViewAdapter;
|
private ContactsActivitySearchAdapter searchListViewAdapter;
|
||||||
|
|
||||||
private boolean searchWas;
|
private boolean searchWas;
|
||||||
private boolean searching;
|
private boolean searching;
|
||||||
private boolean onlyUsers;
|
private boolean onlyUsers;
|
||||||
private boolean usersAsSections;
|
private boolean needPhonebook;
|
||||||
private boolean destroyAfterSelect;
|
private boolean destroyAfterSelect;
|
||||||
private boolean returnAsResult;
|
private boolean returnAsResult;
|
||||||
private boolean createSecretChat;
|
private boolean createSecretChat;
|
||||||
private boolean creatingChat = false;
|
private boolean creatingChat = false;
|
||||||
private String selectAlertString = null;
|
private String selectAlertString = null;
|
||||||
private TextView emptyTextView;
|
|
||||||
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
||||||
|
|
||||||
private String inviteText;
|
|
||||||
private boolean updatingInviteText = false;
|
|
||||||
private boolean allowUsernameSearch = true;
|
private boolean allowUsernameSearch = true;
|
||||||
private ContactsActivityDelegate delegate;
|
private ContactsActivityDelegate delegate;
|
||||||
|
|
||||||
@ -96,19 +89,15 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (arguments != null) {
|
if (arguments != null) {
|
||||||
onlyUsers = getArguments().getBoolean("onlyUsers", false);
|
onlyUsers = getArguments().getBoolean("onlyUsers", false);
|
||||||
destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false);
|
destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false);
|
||||||
usersAsSections = arguments.getBoolean("usersAsSections", false);
|
|
||||||
returnAsResult = arguments.getBoolean("returnAsResult", false);
|
returnAsResult = arguments.getBoolean("returnAsResult", false);
|
||||||
createSecretChat = arguments.getBoolean("createSecretChat", false);
|
createSecretChat = arguments.getBoolean("createSecretChat", false);
|
||||||
selectAlertString = arguments.getString("selectAlertString");
|
selectAlertString = arguments.getString("selectAlertString");
|
||||||
allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true);
|
allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true);
|
||||||
|
} else {
|
||||||
|
needPhonebook = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
ContactsController.getInstance().checkInviteText();
|
||||||
inviteText = preferences.getString("invitetext", null);
|
|
||||||
int time = preferences.getInt("invitetexttime", 0);
|
|
||||||
if (inviteText == null || time + 86400 < (int)(System.currentTimeMillis() / 1000)) {
|
|
||||||
updateInviteText();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -125,6 +114,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
searching = false;
|
||||||
|
searchWas = false;
|
||||||
|
|
||||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||||
if (destroyAfterSelect) {
|
if (destroyAfterSelect) {
|
||||||
@ -157,7 +149,6 @@ 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();
|
||||||
listView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 30 : 16), listView.getPaddingTop(), AndroidUtilities.dp(LocaleController.isRTL ? 16 : 30), listView.getPaddingBottom());
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
listView.setFastScrollAlwaysVisible(true);
|
listView.setFastScrollAlwaysVisible(true);
|
||||||
}
|
}
|
||||||
@ -176,7 +167,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (text.length() != 0) {
|
if (text.length() != 0) {
|
||||||
searchWas = true;
|
searchWas = true;
|
||||||
if (listView != null) {
|
if (listView != null) {
|
||||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
|
||||||
listView.setAdapter(searchListViewAdapter);
|
listView.setAdapter(searchListViewAdapter);
|
||||||
searchListViewAdapter.notifyDataSetChanged();
|
searchListViewAdapter.notifyDataSetChanged();
|
||||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
@ -193,31 +183,48 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.contacts_layout, container, false);
|
|
||||||
|
|
||||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
|
||||||
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
|
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
|
||||||
|
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers);
|
||||||
|
|
||||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
fragmentView = new FrameLayout(getParentActivity());
|
||||||
listView.setEmptyView(emptyTextView);
|
|
||||||
listView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 30 : 16), listView.getPaddingTop(), AndroidUtilities.dp(LocaleController.isRTL ? 16 : 30), listView.getPaddingBottom());
|
emptyTextView = new TextView(getParentActivity());
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
emptyTextView.setTextColor(0xff808080);
|
||||||
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
emptyTextView.setTextSize(24);
|
||||||
}
|
emptyTextView.setGravity(Gravity.CENTER);
|
||||||
|
emptyTextView.setVisibility(View.INVISIBLE);
|
||||||
|
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||||
|
((FrameLayout) fragmentView).addView(emptyTextView);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP;
|
||||||
|
emptyTextView.setLayoutParams(layoutParams);
|
||||||
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) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
|
||||||
|
|
||||||
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, usersAsSections, ignoreUsers);
|
listView = new SectionsListView(getParentActivity());
|
||||||
|
listView.setEmptyView(emptyTextView);
|
||||||
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
listView.setDivider(null);
|
||||||
|
listView.setDividerHeight(0);
|
||||||
|
listView.setFastScrollEnabled(true);
|
||||||
|
listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
|
||||||
listView.setAdapter(listViewAdapter);
|
listView.setAdapter(listViewAdapter);
|
||||||
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
|
listView.setFastScrollAlwaysVisible(true);
|
||||||
|
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
||||||
|
}
|
||||||
|
((FrameLayout) fragmentView).addView(listView);
|
||||||
|
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
listView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
@ -253,86 +260,84 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (row < 0 || section < 0) {
|
if (row < 0 || section < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TLRPC.User user = null;
|
if (!onlyUsers && section == 0) {
|
||||||
if (usersAsSections) {
|
if (needPhonebook) {
|
||||||
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
|
|
||||||
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
|
|
||||||
if (row < arr.size()) {
|
|
||||||
TLRPC.TL_contact contact = arr.get(row);
|
|
||||||
user = MessagesController.getInstance().getUser(contact.user_id);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (section == 0) {
|
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, inviteText != null ? inviteText : LocaleController.getString("InviteText", R.string.InviteText));
|
intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText());
|
||||||
getParentActivity().startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (row - 1 < ContactsController.getInstance().contacts.size()) {
|
|
||||||
user = MessagesController.getInstance().getUser(ContactsController.getInstance().contacts.get(row - 1).user_id);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user != null) {
|
|
||||||
if (user.id == UserConfig.getClientUserId()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (returnAsResult) {
|
|
||||||
if (ignoreUsers != null && ignoreUsers.containsKey(user.id)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
didSelectResult(user, true, null);
|
|
||||||
} else {
|
} else {
|
||||||
if (createSecretChat) {
|
if (row == 0) {
|
||||||
creatingChat = true;
|
presentFragment(new GroupCreateActivity(), true);
|
||||||
MessagesController.getInstance().startSecretChat(getParentActivity(), user);
|
} else if (row == 1) {
|
||||||
} else {
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", user.id);
|
args.putBoolean("onlyUsers", true);
|
||||||
presentFragment(new ChatActivity(args), true);
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
|
args.putBoolean("createSecretChat", true);
|
||||||
|
presentFragment(new ContactsActivity(args), true);
|
||||||
|
} else if (row == 2) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("broadcast", true);
|
||||||
|
presentFragment(new GroupCreateActivity(args), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ArrayList<ContactsController.Contact> arr = ContactsController.getInstance().contactsSectionsDict.get(ContactsController.getInstance().sortedContactsSectionsArray.get(section - 1));
|
Object item = listViewAdapter.getItem(section, row);
|
||||||
ContactsController.Contact contact = arr.get(row);
|
|
||||||
String usePhone = null;
|
if (item instanceof TLRPC.User) {
|
||||||
if (!contact.phones.isEmpty()) {
|
TLRPC.User user = (TLRPC.User) item;
|
||||||
usePhone = contact.phones.get(0);
|
if (user.id == UserConfig.getClientUserId()) {
|
||||||
}
|
return;
|
||||||
if (usePhone == null || getParentActivity() == null) {
|
}
|
||||||
return;
|
if (returnAsResult) {
|
||||||
}
|
if (ignoreUsers != null && ignoreUsers.containsKey(user.id)) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
return;
|
||||||
builder.setMessage(LocaleController.getString("InviteUser", R.string.InviteUser));
|
}
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
didSelectResult(user, true, null);
|
||||||
final String arg1 = usePhone;
|
} else {
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
if (createSecretChat) {
|
||||||
@Override
|
creatingChat = true;
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
MessagesController.getInstance().startSecretChat(getParentActivity(), user);
|
||||||
try {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", arg1, null));
|
Bundle args = new Bundle();
|
||||||
intent.putExtra("sms_body", LocaleController.getString("InviteText", R.string.InviteText));
|
args.putInt("user_id", user.id);
|
||||||
getParentActivity().startActivity(intent);
|
presentFragment(new ChatActivity(args), true);
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
} else if (item instanceof ContactsController.Contact) {
|
||||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
ContactsController.Contact contact = (ContactsController.Contact) item;
|
||||||
showAlertDialog(builder);
|
String usePhone = null;
|
||||||
|
if (!contact.phones.isEmpty()) {
|
||||||
|
usePhone = contact.phones.get(0);
|
||||||
|
}
|
||||||
|
if (usePhone == null || getParentActivity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
builder.setMessage(LocaleController.getString("InviteUser", R.string.InviteUser));
|
||||||
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
|
final String arg1 = usePhone;
|
||||||
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", arg1, null));
|
||||||
|
intent.putExtra("sms_body", LocaleController.getString("InviteText", R.string.InviteText));
|
||||||
|
getParentActivity().startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
|
showAlertDialog(builder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,45 +437,13 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInviteText() {
|
|
||||||
if (!updatingInviteText) {
|
|
||||||
updatingInviteText = true;
|
|
||||||
TLRPC.TL_help_getInviteText req = new TLRPC.TL_help_getInviteText();
|
|
||||||
req.lang_code = LocaleController.getLocaleString(Locale.getDefault());
|
|
||||||
if (req.lang_code == null || req.lang_code.length() == 0) {
|
|
||||||
req.lang_code = "en";
|
|
||||||
}
|
|
||||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
|
||||||
@Override
|
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
|
||||||
if (error == null) {
|
|
||||||
final TLRPC.TL_help_inviteText res = (TLRPC.TL_help_inviteText)response;
|
|
||||||
if (res.message.length() != 0) {
|
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updatingInviteText = false;
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
|
||||||
editor.putString("invitetext", res.message);
|
|
||||||
editor.putInt("invitetexttime", (int) (System.currentTimeMillis() / 1000));
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateVisibleRows(int mask) {
|
private void updateVisibleRows(int mask) {
|
||||||
if (listView != null) {
|
if (listView != null) {
|
||||||
int count = listView.getChildCount();
|
int count = listView.getChildCount();
|
||||||
for (int a = 0; a < count; a++) {
|
for (int a = 0; a < count; a++) {
|
||||||
View child = listView.getChildAt(a);
|
View child = listView.getChildAt(a);
|
||||||
if (child instanceof ChatOrUserCell) {
|
if (child instanceof UserCell) {
|
||||||
((ChatOrUserCell) child).update(mask);
|
((UserCell) child).update(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -568,7 +568,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
|
|
||||||
holder.messageTextView.setText(LocaleController.formatUserStatus(user));
|
holder.messageTextView.setText(LocaleController.formatUserStatus(user));
|
||||||
if (user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime()) {
|
if (user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime()) {
|
||||||
holder.messageTextView.setTextColor(0xff357aa8);
|
holder.messageTextView.setTextColor(0xff548ab6);
|
||||||
} else {
|
} else {
|
||||||
holder.messageTextView.setTextColor(0xff808080);
|
holder.messageTextView.setTextColor(0xff808080);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import org.telegram.messenger.FileLog;
|
|||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.android.NotificationCenter;
|
import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
@ -64,6 +64,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
public GroupCreateFinalActivity(Bundle args) {
|
public GroupCreateFinalActivity(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
isBroadcast = args.getBoolean("broadcast", false);
|
isBroadcast = args.getBoolean("broadcast", false);
|
||||||
|
avatarDrawable = new AvatarDrawable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -339,8 +340,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
int count = listView.getChildCount();
|
int count = listView.getChildCount();
|
||||||
for (int a = 0; a < count; a++) {
|
for (int a = 0; a < count; a++) {
|
||||||
View child = listView.getChildAt(a);
|
View child = listView.getChildAt(a);
|
||||||
if (child instanceof ChatOrUserCell) {
|
if (child instanceof UserCell) {
|
||||||
((ChatOrUserCell) child).update(mask);
|
((UserCell) child).update(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,12 +391,11 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(position));
|
TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(position));
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = new ChatOrUserCell(mContext);
|
convertView = new UserCell(mContext);
|
||||||
((ChatOrUserCell)convertView).usePadding = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
((ChatOrUserCell)convertView).setData(user, null, null, null, null);
|
((UserCell)convertView).setData(user, null, null);
|
||||||
((ChatOrUserCell) convertView).useSeparator = position != selectedContacts.size() - 1;
|
((UserCell) convertView).useSeparator = position != selectedContacts.size() - 1;
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ import org.telegram.android.MessagesController;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.IdenticonView;
|
import org.telegram.ui.Views.IdenticonDrawable;
|
||||||
|
|
||||||
public class IdenticonActivity extends BaseFragment {
|
public class IdenticonActivity extends BaseFragment {
|
||||||
private int chat_id;
|
private int chat_id;
|
||||||
@ -60,11 +61,13 @@ public class IdenticonActivity extends BaseFragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
|
||||||
IdenticonView identiconView = (IdenticonView) fragmentView.findViewById(R.id.identicon_view);
|
ImageView identiconView = (ImageView) fragmentView.findViewById(R.id.identicon_view);
|
||||||
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
|
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
|
||||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
|
||||||
if (encryptedChat != null) {
|
if (encryptedChat != null) {
|
||||||
identiconView.setBytes(encryptedChat.auth_key);
|
IdenticonDrawable drawable = new IdenticonDrawable();
|
||||||
|
identiconView.setImageDrawable(drawable);
|
||||||
|
drawable.setBytes(encryptedChat.auth_key);
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
|
TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
|
||||||
textView.setText(Html.fromHtml(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
|
textView.setText(Html.fromHtml(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.PhoneFormat.PhoneFormat;
|
import org.telegram.PhoneFormat.PhoneFormat;
|
||||||
|
import org.telegram.android.ContactsController;
|
||||||
import org.telegram.android.SendMessagesHelper;
|
import org.telegram.android.SendMessagesHelper;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
@ -204,7 +205,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlyUsers", true);
|
args.putBoolean("onlyUsers", true);
|
||||||
args.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
args.putBoolean("usersAsSections", true);
|
|
||||||
args.putBoolean("createSecretChat", true);
|
args.putBoolean("createSecretChat", true);
|
||||||
presentFragment(new ContactsActivity(args));
|
presentFragment(new ContactsActivity(args));
|
||||||
}
|
}
|
||||||
@ -268,7 +268,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlyUsers", true);
|
args.putBoolean("onlyUsers", true);
|
||||||
args.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
args.putBoolean("usersAsSections", true);
|
|
||||||
args.putBoolean("createSecretChat", true);
|
args.putBoolean("createSecretChat", true);
|
||||||
presentFragment(new ContactsActivity(args));
|
presentFragment(new ContactsActivity(args));
|
||||||
drawerLayoutContainer.closeDrawer(false);
|
drawerLayoutContainer.closeDrawer(false);
|
||||||
@ -277,15 +276,29 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||||||
args.putBoolean("broadcast", true);
|
args.putBoolean("broadcast", true);
|
||||||
presentFragment(new GroupCreateActivity(args));
|
presentFragment(new GroupCreateActivity(args));
|
||||||
drawerLayoutContainer.closeDrawer(false);
|
drawerLayoutContainer.closeDrawer(false);
|
||||||
} else if (position == 8) {
|
} else if (position == 6) {
|
||||||
presentFragment(new ContactsActivity(null));
|
presentFragment(new ContactsActivity(null));
|
||||||
drawerLayoutContainer.closeDrawer(false);
|
drawerLayoutContainer.closeDrawer(false);
|
||||||
} else if (position == 9) {
|
} else if (position == 7) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
|
intent.setType("text/plain");
|
||||||
|
intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText());
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
drawerLayoutContainer.closeDrawer(false);
|
drawerLayoutContainer.closeDrawer(false);
|
||||||
} else if (position == 10) {
|
} else if (position == 8) {
|
||||||
presentFragment(new SettingsActivity());
|
presentFragment(new SettingsActivity());
|
||||||
drawerLayoutContainer.closeDrawer(false);
|
drawerLayoutContainer.closeDrawer(false);
|
||||||
} else if (position == 11) {
|
} else if (position == 9) {
|
||||||
|
try {
|
||||||
|
Intent pickIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)));
|
||||||
|
startActivity(pickIntent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
drawerLayoutContainer.closeDrawer(false);
|
drawerLayoutContainer.closeDrawer(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||||||
}
|
}
|
||||||
codeField.setText("");
|
codeField.setText("");
|
||||||
AndroidUtilities.setWaitingForSms(true);
|
AndroidUtilities.setWaitingForSms(true);
|
||||||
NotificationCenter.getInstance().addObserver(this, 998);
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceiveSmsCode);
|
||||||
currentParams = params;
|
currentParams = params;
|
||||||
waitingForSms = true;
|
waitingForSms = true;
|
||||||
String phone = params.getString("phone");
|
String phone = params.getString("phone");
|
||||||
@ -279,7 +279,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||||||
nextPressed = true;
|
nextPressed = true;
|
||||||
waitingForSms = false;
|
waitingForSms = false;
|
||||||
AndroidUtilities.setWaitingForSms(false);
|
AndroidUtilities.setWaitingForSms(false);
|
||||||
NotificationCenter.getInstance().removeObserver(this, 998);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
|
||||||
final TLRPC.TL_auth_signIn req = new TLRPC.TL_auth_signIn();
|
final TLRPC.TL_auth_signIn req = new TLRPC.TL_auth_signIn();
|
||||||
req.phone_number = requestPhone;
|
req.phone_number = requestPhone;
|
||||||
req.phone_code = codeField.getText().toString();
|
req.phone_code = codeField.getText().toString();
|
||||||
@ -353,7 +353,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||||||
destroyCodeTimer();
|
destroyCodeTimer();
|
||||||
currentParams = null;
|
currentParams = null;
|
||||||
AndroidUtilities.setWaitingForSms(false);
|
AndroidUtilities.setWaitingForSms(false);
|
||||||
NotificationCenter.getInstance().removeObserver(this, 998);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
|
||||||
waitingForSms = false;
|
waitingForSms = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||||||
public void onDestroyActivity() {
|
public void onDestroyActivity() {
|
||||||
super.onDestroyActivity();
|
super.onDestroyActivity();
|
||||||
AndroidUtilities.setWaitingForSms(false);
|
AndroidUtilities.setWaitingForSms(false);
|
||||||
NotificationCenter.getInstance().removeObserver(this, 998);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
|
||||||
destroyTimer();
|
destroyTimer();
|
||||||
destroyCodeTimer();
|
destroyCodeTimer();
|
||||||
waitingForSms = false;
|
waitingForSms = false;
|
||||||
@ -378,7 +378,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didReceivedNotification(int id, final Object... args) {
|
public void didReceivedNotification(int id, final Object... args) {
|
||||||
if (id == 998) {
|
if (id == NotificationCenter.didReceiveSmsCode) {
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -259,6 +259,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (parentLayout != null) {
|
||||||
|
parentLayout.getDrawerLayoutContainer().setStatusBarColor(0xff54759e);
|
||||||
|
}
|
||||||
if (listAdapter != null) {
|
if (listAdapter != null) {
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import org.telegram.ui.Adapters.MessagesActivityAdapter;
|
|||||||
import org.telegram.ui.Adapters.MessagesActivitySearchAdapter;
|
import org.telegram.ui.Adapters.MessagesActivitySearchAdapter;
|
||||||
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
||||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Cells.DialogCell;
|
import org.telegram.ui.Cells.DialogCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
@ -266,9 +266,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlyUsers", true);
|
|
||||||
args.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
args.putBoolean("usersAsSections", true);
|
|
||||||
presentFragment(new ContactsActivity(args));
|
presentFragment(new ContactsActivity(args));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -613,8 +611,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cell.update(mask);
|
cell.update(mask);
|
||||||
} else if (child instanceof ChatOrUserCell) {
|
} else if (child instanceof UserCell) {
|
||||||
((ChatOrUserCell) child).update(mask);
|
((UserCell) child).update(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,17 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ImageButton;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -35,20 +38,28 @@ import org.telegram.android.NotificationCenter;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.android.MessageObject;
|
import org.telegram.android.MessageObject;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
|
import org.telegram.ui.Cells.DividerCell;
|
||||||
|
import org.telegram.ui.Cells.EmptyCell;
|
||||||
|
import org.telegram.ui.Cells.TextCell;
|
||||||
|
import org.telegram.ui.Cells.TextDetailCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.IdenticonView;
|
import org.telegram.ui.Views.IdenticonDrawable;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class UserProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private ListAdapter listAdapter;
|
private ListAdapter listAdapter;
|
||||||
|
private BackupImageView avatarImage;
|
||||||
|
private TextView nameTextView;
|
||||||
|
private TextView onlineTextView;
|
||||||
|
FrameLayout nameContainer;
|
||||||
|
|
||||||
private int user_id;
|
private int user_id;
|
||||||
private int totalMediaCount = -1;
|
private int totalMediaCount = -1;
|
||||||
private boolean creatingChat = false;
|
private boolean creatingChat = false;
|
||||||
@ -62,19 +73,18 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
private final static int edit_contact = 4;
|
private final static int edit_contact = 4;
|
||||||
private final static int delete_contact = 5;
|
private final static int delete_contact = 5;
|
||||||
|
|
||||||
private int avatarRow;
|
private int emptyRow;
|
||||||
private int phoneSectionRow;
|
|
||||||
private int phoneRow;
|
private int phoneRow;
|
||||||
private int usernameRow;
|
private int usernameRow;
|
||||||
private int settingsSectionRow;
|
|
||||||
private int settingsTimerRow;
|
private int settingsTimerRow;
|
||||||
private int settingsKeyRow;
|
private int settingsKeyRow;
|
||||||
private int settingsNotificationsRow;
|
private int settingsNotificationsRow;
|
||||||
private int sharedMediaSectionRow;
|
|
||||||
private int sharedMediaRow;
|
private int sharedMediaRow;
|
||||||
|
private int startSecretChatRow;
|
||||||
|
private int sectionRow;
|
||||||
private int rowCount = 0;
|
private int rowCount = 0;
|
||||||
|
|
||||||
public UserProfileActivity(Bundle args) {
|
public ProfileActivity(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,41 +125,12 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
MessagesController.getInstance().cancelLoadFullUser(user_id);
|
MessagesController.getInstance().cancelLoadFullUser(user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRowsIds() {
|
|
||||||
rowCount = 0;
|
|
||||||
avatarRow = rowCount++;
|
|
||||||
phoneSectionRow = rowCount++;
|
|
||||||
phoneRow = rowCount++;
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
||||||
if (user != null && user.username != null && user.username.length() > 0) {
|
|
||||||
usernameRow = rowCount++;
|
|
||||||
} else {
|
|
||||||
usernameRow = -1;
|
|
||||||
}
|
|
||||||
settingsSectionRow = rowCount++;
|
|
||||||
if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
|
|
||||||
settingsTimerRow = rowCount++;
|
|
||||||
settingsKeyRow = rowCount++;
|
|
||||||
} else {
|
|
||||||
settingsTimerRow = -1;
|
|
||||||
settingsKeyRow = -1;
|
|
||||||
}
|
|
||||||
settingsNotificationsRow = rowCount++;
|
|
||||||
sharedMediaSectionRow = rowCount++;
|
|
||||||
sharedMediaRow = rowCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id));
|
||||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||||
if (dialog_id != 0) {
|
|
||||||
actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
|
|
||||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
|
|
||||||
} else {
|
|
||||||
actionBarLayer.setTitle(LocaleController.getString("ContactInfo", R.string.ContactInfo));
|
|
||||||
}
|
|
||||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(final int id) {
|
public void onItemClick(final int id) {
|
||||||
@ -185,7 +166,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
args.putBoolean("onlySelect", true);
|
args.putBoolean("onlySelect", true);
|
||||||
args.putBoolean("serverOnly", true);
|
args.putBoolean("serverOnly", true);
|
||||||
MessagesActivity fragment = new MessagesActivity(args);
|
MessagesActivity fragment = new MessagesActivity(args);
|
||||||
fragment.setDelegate(UserProfileActivity.this);
|
fragment.setDelegate(ProfileActivity.this);
|
||||||
presentFragment(fragment);
|
presentFragment(fragment);
|
||||||
} else if (id == edit_contact) {
|
} else if (id == edit_contact) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@ -215,44 +196,95 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
|
|
||||||
createActionBarMenu();
|
createActionBarMenu();
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.user_profile_layout, container, false);
|
|
||||||
listAdapter = new ListAdapter(getParentActivity());
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
|
|
||||||
TextView textView = (TextView)fragmentView.findViewById(R.id.start_secret_button_text);
|
fragmentView = new FrameLayout(getParentActivity());
|
||||||
textView.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||||
|
|
||||||
View startSecretButton = fragmentView.findViewById(R.id.start_secret_button);
|
nameContainer = new FrameLayout(getParentActivity());
|
||||||
startSecretButton.setOnClickListener(new View.OnClickListener() {
|
nameContainer.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id));
|
||||||
|
frameLayout.addView(nameContainer);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) nameContainer.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = AndroidUtilities.dp(88);
|
||||||
|
nameContainer.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
avatarImage = new BackupImageView(getParentActivity());
|
||||||
|
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
|
||||||
|
avatarImage.processDetach = false;
|
||||||
|
nameContainer.addView(avatarImage);
|
||||||
|
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
|
||||||
|
layoutParams1.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
|
||||||
|
layoutParams1.width = AndroidUtilities.dp(60);
|
||||||
|
layoutParams1.height = AndroidUtilities.dp(60);
|
||||||
|
layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(17);
|
||||||
|
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(17) : 0;
|
||||||
|
layoutParams1.bottomMargin = AndroidUtilities.dp(22);
|
||||||
|
avatarImage.setLayoutParams(layoutParams1);
|
||||||
|
avatarImage.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View v) {
|
||||||
if (getParentActivity() == null) {
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
return;
|
if (user.photo != null && user.photo.photo_big != null) {
|
||||||
|
PhotoViewer.getInstance().setParentActivity(getParentActivity());
|
||||||
|
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ProfileActivity.this);
|
||||||
}
|
}
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
||||||
builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat));
|
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
creatingChat = true;
|
|
||||||
MessagesController.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().getUser(user_id));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
||||||
showAlertDialog(builder);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (dialog_id == 0) {
|
|
||||||
startSecretButton.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
startSecretButton.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
nameTextView = new TextView(getParentActivity());
|
||||||
|
nameTextView.setTextColor(0xffffffff);
|
||||||
|
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||||
|
nameTextView.setLines(1);
|
||||||
|
nameTextView.setMaxLines(1);
|
||||||
|
nameTextView.setSingleLine(true);
|
||||||
|
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||||
|
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
nameContainer.addView(nameTextView);
|
||||||
|
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||||
|
layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97);
|
||||||
|
layoutParams1.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16);
|
||||||
|
layoutParams1.bottomMargin = AndroidUtilities.dp(51);
|
||||||
|
layoutParams1.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
|
||||||
|
nameTextView.setLayoutParams(layoutParams1);
|
||||||
|
|
||||||
|
onlineTextView = new TextView(getParentActivity());
|
||||||
|
onlineTextView.setTextColor(0xffd0e4ea);
|
||||||
|
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||||
|
onlineTextView.setLines(1);
|
||||||
|
onlineTextView.setMaxLines(1);
|
||||||
|
onlineTextView.setSingleLine(true);
|
||||||
|
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||||
|
nameContainer.addView(onlineTextView);
|
||||||
|
layoutParams1 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
|
||||||
|
layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97);
|
||||||
|
layoutParams1.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16);
|
||||||
|
layoutParams1.bottomMargin = AndroidUtilities.dp(30);
|
||||||
|
layoutParams1.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
|
||||||
|
onlineTextView.setLayoutParams(layoutParams1);
|
||||||
|
|
||||||
|
listView = new ListView(getParentActivity());
|
||||||
|
listView.setDivider(null);
|
||||||
|
listView.setDividerHeight(0);
|
||||||
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
frameLayout.addView(listView);
|
||||||
|
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(88);
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
listView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||||
|
if (getParentActivity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (i == sharedMediaRow) {
|
if (i == sharedMediaRow) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
if (dialog_id != 0) {
|
if (dialog_id != 0) {
|
||||||
@ -274,6 +306,50 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("dialog_id", dialog_id == 0 ? user_id : dialog_id);
|
args.putLong("dialog_id", dialog_id == 0 ? user_id : dialog_id);
|
||||||
presentFragment(new ProfileNotificationsActivity(args));
|
presentFragment(new ProfileNotificationsActivity(args));
|
||||||
|
} else if (i == startSecretChatRow) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat));
|
||||||
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
creatingChat = true;
|
||||||
|
MessagesController.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().getUser(user_id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
|
showAlertDialog(builder);
|
||||||
|
} else if (i == phoneRow) {
|
||||||
|
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
|
if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
builder.setItems(new CharSequence[] {LocaleController.getString("Call", R.string.Call), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
if (i == 0) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone));
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
getParentActivity().startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
} else if (i == 1) {
|
||||||
|
if(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
clipboard.setText(user.phone);
|
||||||
|
} else {
|
||||||
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
android.content.ClipData clip = android.content.ClipData.newPlainText("label", user.phone);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
showAlertDialog(builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -282,6 +358,33 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
} else {
|
} else {
|
||||||
MessagesController.getInstance().getMediaCount(user_id, classGuid, true);
|
MessagesController.getInstance().getMediaCount(user_id, classGuid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageView writeButton = new ImageView(getParentActivity());
|
||||||
|
writeButton.setImageResource(R.drawable.floating_states);
|
||||||
|
frameLayout.addView(writeButton);
|
||||||
|
layoutParams1 = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
|
||||||
|
layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
|
||||||
|
layoutParams1.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
|
||||||
|
layoutParams1.topMargin = AndroidUtilities.dp(58);
|
||||||
|
layoutParams1.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT);
|
||||||
|
writeButton.setLayoutParams(layoutParams1);
|
||||||
|
writeButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
|
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt("user_id", user_id);
|
||||||
|
presentFragment(new ChatActivity(args), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateUserData();
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -295,10 +398,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if (id == NotificationCenter.updateInterfaces) {
|
if (id == NotificationCenter.updateInterfaces) {
|
||||||
int mask = (Integer)args[0];
|
int mask = (Integer)args[0];
|
||||||
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
|
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
|
||||||
updateRowsIds();
|
updateUserData();
|
||||||
if (listView != null) {
|
|
||||||
listView.invalidateViews();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (id == NotificationCenter.contactsDidLoaded) {
|
} else if (id == NotificationCenter.contactsDidLoaded) {
|
||||||
createActionBarMenu();
|
createActionBarMenu();
|
||||||
@ -344,6 +444,9 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (parentLayout != null) {
|
||||||
|
parentLayout.getDrawerLayoutContainer().setStatusBarColor(AvatarDrawable.getProfileBackColorForId(user_id));
|
||||||
|
}
|
||||||
if (listAdapter != null) {
|
if (listAdapter != null) {
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
@ -358,24 +461,17 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
||||||
TLRPC.FileLocation photoBig = user.photo.photo_big;
|
TLRPC.FileLocation photoBig = user.photo.photo_big;
|
||||||
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
|
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
|
||||||
int count = listView.getChildCount();
|
int coords[] = new int[2];
|
||||||
for (int a = 0; a < count; a++) {
|
avatarImage.getLocationInWindow(coords);
|
||||||
View view = listView.getChildAt(a);
|
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||||
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
object.viewX = coords[0];
|
||||||
if (avatarImage != null) {
|
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
||||||
int coords[] = new int[2];
|
object.parentView = nameContainer;
|
||||||
avatarImage.getLocationInWindow(coords);
|
object.imageReceiver = avatarImage.imageReceiver;
|
||||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
object.user_id = user_id;
|
||||||
object.viewX = coords[0];
|
object.thumb = object.imageReceiver.getBitmap();
|
||||||
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
object.size = -1;
|
||||||
object.parentView = listView;
|
return object;
|
||||||
object.imageReceiver = avatarImage.imageReceiver;
|
|
||||||
object.user_id = user_id;
|
|
||||||
object.thumb = object.imageReceiver.getBitmap();
|
|
||||||
object.size = -1;
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -402,6 +498,50 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
@Override
|
@Override
|
||||||
public int getSelectedCount() { return 0; }
|
public int getSelectedCount() { return 0; }
|
||||||
|
|
||||||
|
private void updateRowsIds() {
|
||||||
|
rowCount = 0;
|
||||||
|
emptyRow = rowCount++;
|
||||||
|
phoneRow = rowCount++;
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
|
if (user != null && user.username != null && user.username.length() > 0) {
|
||||||
|
usernameRow = rowCount++;
|
||||||
|
} else {
|
||||||
|
usernameRow = -1;
|
||||||
|
}
|
||||||
|
sectionRow = rowCount++;
|
||||||
|
if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
|
||||||
|
settingsTimerRow = rowCount++;
|
||||||
|
settingsKeyRow = rowCount++;
|
||||||
|
} else {
|
||||||
|
settingsTimerRow = -1;
|
||||||
|
settingsKeyRow = -1;
|
||||||
|
}
|
||||||
|
settingsNotificationsRow = rowCount++;
|
||||||
|
sharedMediaRow = rowCount++;
|
||||||
|
if (currentEncryptedChat == null) {
|
||||||
|
startSecretChatRow = rowCount++;
|
||||||
|
} else {
|
||||||
|
startSecretChatRow = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUserData() {
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
|
TLRPC.FileLocation photo = null;
|
||||||
|
TLRPC.FileLocation photoBig = null;
|
||||||
|
if (user.photo != null) {
|
||||||
|
photo = user.photo.photo_small;
|
||||||
|
photoBig = user.photo.photo_big;
|
||||||
|
}
|
||||||
|
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user, true));
|
||||||
|
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||||
|
|
||||||
|
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||||
|
onlineTextView.setText(LocaleController.formatUserStatus(user));
|
||||||
|
|
||||||
|
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||||
|
}
|
||||||
|
|
||||||
private void createActionBarMenu() {
|
private void createActionBarMenu() {
|
||||||
ActionBarMenu menu = actionBarLayer.createMenu();
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
menu.clearItems();
|
menu.clearItems();
|
||||||
@ -472,7 +612,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled(int i) {
|
public boolean isEnabled(int i) {
|
||||||
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow;
|
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == startSecretChatRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -499,191 +639,72 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
int type = getItemViewType(i);
|
int type = getItemViewType(i);
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
BackupImageView avatarImage;
|
|
||||||
TextView onlineText;
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
view = new EmptyCell(mContext, 36);
|
||||||
view = li.inflate(R.layout.user_profile_avatar_layout, viewGroup, false);
|
|
||||||
|
|
||||||
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
|
||||||
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
|
||||||
avatarImage.processDetach = false;
|
|
||||||
avatarImage.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
||||||
if (user.photo != null && user.photo.photo_big != null) {
|
|
||||||
PhotoViewer.getInstance().setParentActivity(getParentActivity());
|
|
||||||
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, UserProfileActivity.this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
|
||||||
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
|
||||||
}
|
}
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_name);
|
|
||||||
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
|
|
||||||
textView.setTypeface(typeface);
|
|
||||||
|
|
||||||
textView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
|
||||||
onlineText.setText(LocaleController.formatUserStatus(user));
|
|
||||||
|
|
||||||
TLRPC.FileLocation photo = null;
|
|
||||||
TLRPC.FileLocation photoBig = null;
|
|
||||||
if (user.photo != null) {
|
|
||||||
photo = user.photo.photo_small;
|
|
||||||
photoBig = user.photo.photo_big;
|
|
||||||
}
|
|
||||||
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user));
|
|
||||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
|
||||||
return view;
|
|
||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new SettingsSectionLayout(mContext);
|
view = new DividerCell(mContext);
|
||||||
}
|
view.setPadding(AndroidUtilities.dp(72), 0, 0, 0);
|
||||||
if (i == phoneSectionRow) {
|
|
||||||
((SettingsSectionLayout) view).setText(LocaleController.getString("Info", R.string.Info));
|
|
||||||
} else if (i == settingsSectionRow) {
|
|
||||||
((SettingsSectionLayout) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS));
|
|
||||||
} else if (i == sharedMediaSectionRow) {
|
|
||||||
((SettingsSectionLayout) view).setText(LocaleController.getString("SHAREDMEDIA", R.string.SHAREDMEDIA));
|
|
||||||
}
|
}
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
view = new TextDetailCell(mContext);
|
||||||
view = li.inflate(R.layout.user_profile_phone_layout, viewGroup, false);
|
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (user.phone == null || user.phone.length() == 0 || getParentActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
||||||
|
|
||||||
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
if (i == 0) {
|
|
||||||
int sdk = android.os.Build.VERSION.SDK_INT;
|
|
||||||
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
|
||||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
clipboard.setText(user.phone);
|
|
||||||
} else {
|
|
||||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
android.content.ClipData clip = android.content.ClipData.newPlainText("label", user.phone);
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
showAlertDialog(builder);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ImageButton button = (ImageButton)view.findViewById(R.id.settings_edit_name);
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
||||||
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putInt("user_id", user_id);
|
|
||||||
presentFragment(new ChatActivity(args), true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
button = (ImageButton)view.findViewById(R.id.settings_call_phone);
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
try {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone));
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
getParentActivity().startActivity(intent);
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
ImageButton button = (ImageButton)view.findViewById(R.id.settings_call_phone);
|
TextDetailCell textDetailCell = (TextDetailCell) view;
|
||||||
button.setVisibility(user.phone == null || user.phone.length() == 0 ? View.GONE : View.VISIBLE);
|
|
||||||
|
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
||||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
|
||||||
View divider = view.findViewById(R.id.settings_row_divider);
|
|
||||||
if (i == phoneRow) {
|
if (i == phoneRow) {
|
||||||
|
String text;
|
||||||
if (user.phone != null && user.phone.length() != 0) {
|
if (user.phone != null && user.phone.length() != 0) {
|
||||||
textView.setText(PhoneFormat.getInstance().format("+" + user.phone));
|
text = PhoneFormat.getInstance().format("+" + user.phone);
|
||||||
} else {
|
} else {
|
||||||
textView.setText(LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
|
text = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
|
||||||
}
|
}
|
||||||
divider.setVisibility(usernameRow != -1 ? View.VISIBLE : View.INVISIBLE);
|
textDetailCell.setTextAndValue(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile));
|
||||||
detailTextView.setText(LocaleController.getString("PhoneMobile", R.string.PhoneMobile));
|
} else if (i == usernameRow) {
|
||||||
|
String text;
|
||||||
|
if (user != null && user.username != null && user.username.length() != 0) {
|
||||||
|
text = "@" + user.username;
|
||||||
|
} else {
|
||||||
|
text = "-";
|
||||||
|
}
|
||||||
|
textDetailCell.setTextAndValue(text, LocaleController.getString("Username", R.string.Username));
|
||||||
}
|
}
|
||||||
} else if (type == 3) {
|
} else if (type == 3) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
view = new TextCell(mContext);
|
||||||
view = li.inflate(R.layout.user_profile_leftright_row_layout, viewGroup, false);
|
|
||||||
}
|
}
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
TextCell textCell = (TextCell) view;
|
||||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
textCell.setTextColor(0xff000000);
|
||||||
|
|
||||||
View divider = view.findViewById(R.id.settings_row_divider);
|
|
||||||
if (i == sharedMediaRow) {
|
if (i == sharedMediaRow) {
|
||||||
textView.setText(LocaleController.getString("SharedMedia", R.string.SharedMedia));
|
String value;
|
||||||
if (totalMediaCount == -1) {
|
if (totalMediaCount == -1) {
|
||||||
detailTextView.setText(LocaleController.getString("Loading", R.string.Loading));
|
value = LocaleController.getString("Loading", R.string.Loading);
|
||||||
} else {
|
} else {
|
||||||
detailTextView.setText(String.format("%d", totalMediaCount));
|
value = String.format("%d", totalMediaCount);
|
||||||
}
|
}
|
||||||
divider.setVisibility(View.INVISIBLE);
|
textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value);
|
||||||
} else if (i == settingsTimerRow) {
|
} else if (i == settingsTimerRow) {
|
||||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
||||||
textView.setText(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
String value;
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
if (encryptedChat.ttl == 0) {
|
if (encryptedChat.ttl == 0) {
|
||||||
detailTextView.setText(LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever));
|
value = LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever);
|
||||||
} else {
|
} else {
|
||||||
detailTextView.setText(AndroidUtilities.formatTTLString(encryptedChat.ttl));
|
value = AndroidUtilities.formatTTLString(encryptedChat.ttl);
|
||||||
}
|
}
|
||||||
} else if (i == usernameRow) {
|
textCell.setTextAndValue(LocaleController.getString("MessageLifetime", R.string.MessageLifetime), value);
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
} else if (i == settingsNotificationsRow) {
|
||||||
textView.setText(LocaleController.getString("Username", R.string.Username));
|
textCell.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||||
if (user != null && user.username != null && user.username.length() != 0) {
|
} else if (i == startSecretChatRow) {
|
||||||
detailTextView.setText("@" + user.username);
|
textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
||||||
} else {
|
textCell.setTextColor(0xff37a919);
|
||||||
detailTextView.setText("-");
|
} else if (i == settingsKeyRow) {
|
||||||
}
|
IdenticonDrawable identiconDrawable = new IdenticonDrawable();
|
||||||
divider.setVisibility(View.INVISIBLE);
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
||||||
}
|
identiconDrawable.setBytes(encryptedChat.auth_key);
|
||||||
} else if (type == 4) {
|
textCell.setTextAndValueDrawable(LocaleController.getString("EncryptionKey", R.string.EncryptionKey), identiconDrawable);
|
||||||
if (view == null) {
|
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
view = li.inflate(R.layout.user_profile_identicon_layout, viewGroup, false);
|
|
||||||
}
|
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
||||||
View divider = view.findViewById(R.id.settings_row_divider);
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
IdenticonView identiconView = (IdenticonView)view.findViewById(R.id.identicon_view);
|
|
||||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
|
||||||
identiconView.setBytes(encryptedChat.auth_key);
|
|
||||||
textView.setText(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
|
||||||
} else if (type == 5) {
|
|
||||||
if (view == null) {
|
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
view = li.inflate(R.layout.settings_row_button_layout, viewGroup, false);
|
|
||||||
}
|
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
||||||
View divider = view.findViewById(R.id.settings_row_divider);
|
|
||||||
if (i == settingsNotificationsRow) {
|
|
||||||
textView.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
|
||||||
divider.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
@ -691,25 +712,21 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int i) {
|
public int getItemViewType(int i) {
|
||||||
if (i == avatarRow) {
|
if (i == emptyRow) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (i == phoneSectionRow || i == settingsSectionRow || i == sharedMediaSectionRow) {
|
} else if (i == sectionRow) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (i == phoneRow) {
|
} else if (i == phoneRow || i == usernameRow) {
|
||||||
return 2;
|
return 2;
|
||||||
} else if (i == sharedMediaRow || i == settingsTimerRow || i == usernameRow) {
|
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == startSecretChatRow || i == settingsKeyRow) {
|
||||||
return 3;
|
return 3;
|
||||||
} else if (i == settingsKeyRow) {
|
|
||||||
return 4;
|
|
||||||
} else if (i == settingsNotificationsRow) {
|
|
||||||
return 5;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewTypeCount() {
|
public int getViewTypeCount() {
|
||||||
return 6;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -253,6 +253,14 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (parentLayout != null) {
|
||||||
|
parentLayout.getDrawerLayoutContainer().setStatusBarColor(0xff54759e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateServerNotificationsSettings() {
|
public void updateServerNotificationsSettings() {
|
||||||
if ((int)dialog_id == 0) {
|
if ((int)dialog_id == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -27,7 +27,7 @@ import org.telegram.android.MessagesController;
|
|||||||
import org.telegram.android.NotificationCenter;
|
import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
@ -72,7 +72,6 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
|||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlyUsers", true);
|
args.putBoolean("onlyUsers", true);
|
||||||
args.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
args.putBoolean("usersAsSections", true);
|
|
||||||
args.putBoolean("returnAsResult", true);
|
args.putBoolean("returnAsResult", true);
|
||||||
ContactsActivity fragment = new ContactsActivity(args);
|
ContactsActivity fragment = new ContactsActivity(args);
|
||||||
fragment.setDelegate(SettingsBlockedUsersActivity.this);
|
fragment.setDelegate(SettingsBlockedUsersActivity.this);
|
||||||
@ -111,7 +110,7 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
|||||||
if (i < MessagesController.getInstance().blockedUsers.size()) {
|
if (i < MessagesController.getInstance().blockedUsers.size()) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", MessagesController.getInstance().blockedUsers.get(i));
|
args.putInt("user_id", MessagesController.getInstance().blockedUsers.get(i));
|
||||||
presentFragment(new UserProfileActivity(args));
|
presentFragment(new ProfileActivity(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -177,8 +176,8 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
|||||||
int count = listView.getChildCount();
|
int count = listView.getChildCount();
|
||||||
for (int a = 0; a < count; a++) {
|
for (int a = 0; a < count; a++) {
|
||||||
View child = listView.getChildAt(a);
|
View child = listView.getChildAt(a);
|
||||||
if (child instanceof ChatOrUserCell) {
|
if (child instanceof UserCell) {
|
||||||
((ChatOrUserCell) child).update(mask);
|
((UserCell) child).update(mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,12 +243,11 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
|||||||
int type = getItemViewType(i);
|
int type = getItemViewType(i);
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new ChatOrUserCell(mContext);
|
view = new UserCell(mContext);
|
||||||
((ChatOrUserCell)view).usePadding = false;
|
((UserCell)view).useSeparator = true;
|
||||||
((ChatOrUserCell)view).useSeparator = true;
|
|
||||||
}
|
}
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(MessagesController.getInstance().blockedUsers.get(i));
|
TLRPC.User user = MessagesController.getInstance().getUser(MessagesController.getInstance().blockedUsers.get(i));
|
||||||
((ChatOrUserCell)view).setData(user, null, null, null, user.phone != null && user.phone.length() != 0 ? PhoneFormat.getInstance().format("+" + user.phone) : LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
|
((UserCell)view).setData(user, null, user.phone != null && user.phone.length() != 0 ? PhoneFormat.getInstance().format("+" + user.phone) : LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
|
||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
@ -16,6 +16,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -222,7 +223,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||||||
if (requestCode == 10) {
|
if (requestCode == 10) {
|
||||||
Utilities.addMediaToGallery(currentPicturePath);
|
Utilities.addMediaToGallery(currentPicturePath);
|
||||||
try {
|
try {
|
||||||
Bitmap bitmap = ImageLoader.loadBitmap(currentPicturePath, null, AndroidUtilities.dp(320), AndroidUtilities.dp(480));
|
Point screenSize = AndroidUtilities.getRealScreenSize();
|
||||||
|
Bitmap bitmap = ImageLoader.loadBitmap(currentPicturePath, null, screenSize.x, screenSize.y);
|
||||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
|
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.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);
|
||||||
@ -238,7 +240,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Bitmap bitmap = ImageLoader.loadBitmap(null, data.getData(), AndroidUtilities.dp(320), AndroidUtilities.dp(480));
|
Point screenSize = AndroidUtilities.getRealScreenSize();
|
||||||
|
Bitmap bitmap = ImageLoader.loadBitmap(null, data.getData(), screenSize.x, screenSize.y);
|
||||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
|
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.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);
|
||||||
|
@ -26,11 +26,14 @@ public class AvatarDrawable extends Drawable {
|
|||||||
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
private static TextPaint namePaint;
|
private static TextPaint namePaint;
|
||||||
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a};
|
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a};
|
||||||
|
private static int[] arrColorsProfiles = {0xffd86f65, 0xffdc9663, 0xffdebc68, 0xff67b35d, 0xff56a2bb, 0xff5c98cd, 0xff8c79d2, 0xffda738e};
|
||||||
|
private static int[] arrColorsProfilesBack = {0xffca6056, 0xffcf8550, 0xffcfa742, 0xff56a14c, 0xff4492ac, 0xff4c84b6, 0xff7d6ac4, 0xffc9637e};
|
||||||
|
|
||||||
private int color;
|
private int color;
|
||||||
private StaticLayout textLayout;
|
private StaticLayout textLayout;
|
||||||
private float textWidth;
|
private float textWidth;
|
||||||
private float textHeight;
|
private float textHeight;
|
||||||
|
private boolean isProfile;
|
||||||
|
|
||||||
public AvatarDrawable() {
|
public AvatarDrawable() {
|
||||||
super();
|
super();
|
||||||
@ -56,10 +59,28 @@ public class AvatarDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AvatarDrawable(TLRPC.User user, boolean profile) {
|
||||||
|
this(user);
|
||||||
|
isProfile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AvatarDrawable(TLRPC.Chat chat, boolean profile) {
|
||||||
|
this(chat);
|
||||||
|
isProfile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getColorForId(int id) {
|
public static int getColorForId(int id) {
|
||||||
return arrColors[Math.abs(id) % arrColors.length];
|
return arrColors[Math.abs(id) % arrColors.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getProfileColorForId(int id) {
|
||||||
|
return arrColorsProfiles[Math.abs(id) % arrColorsProfiles.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getProfileBackColorForId(int id) {
|
||||||
|
return arrColorsProfilesBack[Math.abs(id) % arrColorsProfilesBack.length];
|
||||||
|
}
|
||||||
|
|
||||||
public void setInfo(TLRPC.User user) {
|
public void setInfo(TLRPC.User user) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
setInfo(user.id, user.first_name, user.last_name, false);
|
setInfo(user.id, user.first_name, user.last_name, false);
|
||||||
@ -77,7 +98,11 @@ public class AvatarDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) {
|
public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) {
|
||||||
color = arrColors[Math.abs(id) % arrColors.length];
|
if (isProfile) {
|
||||||
|
color = arrColorsProfiles[Math.abs(id) % arrColors.length];
|
||||||
|
} else {
|
||||||
|
color = arrColors[Math.abs(id) % arrColors.length];
|
||||||
|
}
|
||||||
|
|
||||||
String text = "";
|
String text = "";
|
||||||
if (firstName != null && firstName.length() > 0) {
|
if (firstName != null && firstName.length() > 0) {
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* This is the source code of Telegram for Android v. 1.3.2.
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
* It is licensed under GNU GPL v. 2 or later.
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
* You should have received a copy of the license in this archive (see LICENSE).
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
*
|
*
|
||||||
* Copyright Nikolai Kudashov, 2013.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views;
|
package org.telegram.ui.Views;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.util.AttributeSet;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
|
||||||
public class IdenticonView extends View {
|
public class IdenticonDrawable extends Drawable {
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
private Paint paint = new Paint();
|
private Paint paint = new Paint();
|
||||||
private int colors[] = {
|
private int colors[] = {
|
||||||
@ -26,18 +26,6 @@ public class IdenticonView extends View {
|
|||||||
0xff2f99c9
|
0xff2f99c9
|
||||||
};
|
};
|
||||||
|
|
||||||
public IdenticonView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdenticonView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdenticonView(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_bits(int bitOffset, int numBits) {
|
int get_bits(int bitOffset, int numBits) {
|
||||||
numBits = (int)Math.pow(2, numBits) - 1;
|
numBits = (int)Math.pow(2, numBits) - 1;
|
||||||
int offset = bitOffset / 8;
|
int offset = bitOffset / 8;
|
||||||
@ -56,20 +44,19 @@ public class IdenticonView extends View {
|
|||||||
System.arraycopy(data, 0, temp, 0, data.length);
|
System.arraycopy(data, 0, temp, 0, data.length);
|
||||||
data = temp;
|
data = temp;
|
||||||
}
|
}
|
||||||
invalidate();
|
invalidateSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitPointer = 0;
|
int bitPointer = 0;
|
||||||
float rectSize = (float)Math.floor(Math.min(getWidth(), getHeight()) / 8.0f);
|
float rectSize = (float)Math.floor(Math.min(getBounds().width(), getBounds().height()) / 8.0f);
|
||||||
float xOffset = Math.max(0, (getWidth() - rectSize * 8) / 2);
|
float xOffset = Math.max(0, (getBounds().width() - rectSize * 8) / 2);
|
||||||
float yOffset = Math.max(0, (getHeight() - rectSize * 8) / 2);
|
float yOffset = Math.max(0, (getBounds().height() - rectSize * 8) / 2);
|
||||||
for (int iy = 0; iy < 8; iy++) {
|
for (int iy = 0; iy < 8; iy++) {
|
||||||
for (int ix = 0; ix < 8; ix++) {
|
for (int ix = 0; ix < 8; ix++) {
|
||||||
int byteValue = get_bits(bitPointer, 2);
|
int byteValue = get_bits(bitPointer, 2);
|
||||||
@ -80,4 +67,29 @@ public class IdenticonView extends View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAlpha(int alpha) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColorFilter(ColorFilter cf) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOpacity() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIntrinsicWidth() {
|
||||||
|
return AndroidUtilities.dp(32);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIntrinsicHeight() {
|
||||||
|
return AndroidUtilities.dp(32);
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
package org.telegram.ui.Views;
|
package org.telegram.ui.Views;
|
||||||
|
|
||||||
import android.database.DataSetObserver;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -223,11 +222,4 @@ public abstract class SectionedBaseAdapter extends BaseFragmentAdapter implement
|
|||||||
mSectionCount = getSectionCount();
|
mSectionCount = getSectionCount();
|
||||||
return mSectionCount;
|
return mSectionCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
|
||||||
if (observer != null) {
|
|
||||||
super.unregisterDataSetObserver(observer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,215 @@
|
|||||||
|
/*
|
||||||
|
* 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.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AbsListView;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import org.telegram.messenger.FileLog;
|
||||||
|
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class SectionsListView extends ListView implements AbsListView.OnScrollListener {
|
||||||
|
|
||||||
|
private ArrayList<View> headers = new ArrayList<View>();
|
||||||
|
private ArrayList<View> headersCache = new ArrayList<View>();
|
||||||
|
private OnScrollListener mOnScrollListener;
|
||||||
|
private BaseSectionsAdapter mAdapter;
|
||||||
|
private int currentFirst = -1;
|
||||||
|
private int currentVisible = -1;
|
||||||
|
private int startSection;
|
||||||
|
private int sectionsCount;
|
||||||
|
|
||||||
|
public SectionsListView(Context context) {
|
||||||
|
super(context);
|
||||||
|
super.setOnScrollListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SectionsListView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
super.setOnScrollListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SectionsListView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
super.setOnScrollListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAdapter(ListAdapter adapter) {
|
||||||
|
if (mAdapter == adapter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
headers.clear();
|
||||||
|
headersCache.clear();
|
||||||
|
if (adapter instanceof BaseSectionsAdapter) {
|
||||||
|
mAdapter = (BaseSectionsAdapter) adapter;
|
||||||
|
} else {
|
||||||
|
mAdapter = null;
|
||||||
|
}
|
||||||
|
super.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||||
|
if (mOnScrollListener != null) {
|
||||||
|
mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
|
||||||
|
}
|
||||||
|
if (mAdapter == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
headersCache.addAll(headers);
|
||||||
|
headers.clear();
|
||||||
|
|
||||||
|
if (mAdapter.getCount() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentFirst != firstVisibleItem || currentVisible != visibleItemCount) {
|
||||||
|
currentFirst = firstVisibleItem;
|
||||||
|
currentVisible = visibleItemCount;
|
||||||
|
|
||||||
|
sectionsCount = 1;
|
||||||
|
startSection = mAdapter.getSectionForPosition(firstVisibleItem);
|
||||||
|
int itemNum = firstVisibleItem + mAdapter.getCountForSection(startSection) - mAdapter.getPositionInSectionForPosition(firstVisibleItem);
|
||||||
|
while (true) {
|
||||||
|
if (itemNum >= firstVisibleItem + visibleItemCount) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
itemNum += mAdapter.getCountForSection(startSection + sectionsCount);
|
||||||
|
sectionsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int itemNum = firstVisibleItem;
|
||||||
|
for (int a = startSection; a < startSection + sectionsCount; a++) {
|
||||||
|
View header = null;
|
||||||
|
if (!headersCache.isEmpty()) {
|
||||||
|
header = headersCache.get(0);
|
||||||
|
headersCache.remove(0);
|
||||||
|
}
|
||||||
|
header = getSectionHeaderView(a, header);
|
||||||
|
headers.add(header);
|
||||||
|
int count = mAdapter.getCountForSection(a);
|
||||||
|
if (a == startSection) {
|
||||||
|
int pos = mAdapter.getPositionInSectionForPosition(itemNum);
|
||||||
|
if (pos == count - 1) {
|
||||||
|
header.setTag(-header.getHeight());
|
||||||
|
} else if (pos == count - 2) {
|
||||||
|
View child = getChildAt(itemNum - firstVisibleItem);
|
||||||
|
int headerTop = child.getTop();
|
||||||
|
if (headerTop < 0) {
|
||||||
|
header.setTag(headerTop);
|
||||||
|
} else {
|
||||||
|
header.setTag(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header.setTag(0);
|
||||||
|
}
|
||||||
|
itemNum += count - mAdapter.getPositionInSectionForPosition(firstVisibleItem);
|
||||||
|
} else {
|
||||||
|
View child = getChildAt(itemNum - firstVisibleItem);
|
||||||
|
header.setTag(child.getTop());
|
||||||
|
itemNum += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
|
if (mOnScrollListener != null) {
|
||||||
|
mOnScrollListener.onScrollStateChanged(view, scrollState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private View getSectionHeaderView(int section, View oldView) {
|
||||||
|
boolean shouldLayout = oldView == null;
|
||||||
|
View view = mAdapter.getSectionHeaderView(section, oldView, this);
|
||||||
|
if (shouldLayout) {
|
||||||
|
ensurePinnedHeaderLayout(view, false);
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
|
super.onSizeChanged(w, h, oldw, oldh);
|
||||||
|
if (mAdapter == null || headers.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (View header : headers) {
|
||||||
|
ensurePinnedHeaderLayout(header, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
|
||||||
|
if (header.isLayoutRequested() || forceLayout) {
|
||||||
|
ViewGroup.LayoutParams layoutParams = header.getLayoutParams();
|
||||||
|
int heightSpec = MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY);
|
||||||
|
int widthSpec = MeasureSpec.makeMeasureSpec(layoutParams.width, MeasureSpec.EXACTLY);
|
||||||
|
try {
|
||||||
|
header.measure(widthSpec, heightSpec);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
|
super.dispatchDraw(canvas);
|
||||||
|
if (mAdapter == null || headers.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (View header : headers) {
|
||||||
|
int saveCount = canvas.save();
|
||||||
|
int top = (Integer)header.getTag();
|
||||||
|
canvas.translate(0, top);
|
||||||
|
canvas.clipRect(0, 0, getWidth(), header.getMeasuredHeight());
|
||||||
|
if (top < 0) {
|
||||||
|
canvas.saveLayerAlpha(0, top, header.getWidth(), top + canvas.getHeight(), (int)(255 * (1.0f + (float)top / (float)header.getMeasuredHeight())), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
|
||||||
|
}
|
||||||
|
header.draw(canvas);
|
||||||
|
canvas.restoreToCount(saveCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnScrollListener(OnScrollListener l) {
|
||||||
|
mOnScrollListener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnItemClickListener(SectionsListView.OnItemClickListener listener) {
|
||||||
|
super.setOnItemClickListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class OnItemClickListener implements AdapterView.OnItemClickListener {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
|
||||||
|
SectionedBaseAdapter adapter = (SectionedBaseAdapter) adapterView.getAdapter();
|
||||||
|
int section = adapter.getSectionForPosition(rawPosition);
|
||||||
|
int position = adapter.getPositionInSectionForPosition(rawPosition);
|
||||||
|
onItemClick(adapterView, view, section, position, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onItemClick(AdapterView<?> adapterView, View view, int section, int position, long id);
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 940 B |
BIN
TMessagesProj/src/main/res/drawable-hdpi/broadcast_w.png
Executable file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 552 B |
BIN
TMessagesProj/src/main/res/drawable-hdpi/header_shadow.png
Executable file
After Width: | Height: | Size: 945 B |
Before Width: | Height: | Size: 282 B |
BIN
TMessagesProj/src/main/res/drawable-hdpi/list_group.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
BIN
TMessagesProj/src/main/res/drawable-hdpi/list_secret.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
TMessagesProj/src/main/res/drawable-hdpi/phone.png
Executable file
After Width: | Height: | Size: 1.4 KiB |
BIN
TMessagesProj/src/main/res/drawable-hdpi/popup_fixed.9.png
Normal file → Executable file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 653 B |
BIN
TMessagesProj/src/main/res/drawable-mdpi/broadcast_w.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 377 B |
BIN
TMessagesProj/src/main/res/drawable-mdpi/header_shadow.png
Executable file
After Width: | Height: | Size: 939 B |
Before Width: | Height: | Size: 229 B |
BIN
TMessagesProj/src/main/res/drawable-mdpi/list_group.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
TMessagesProj/src/main/res/drawable-mdpi/list_secret.png
Executable file
After Width: | Height: | Size: 1.0 KiB |
BIN
TMessagesProj/src/main/res/drawable-mdpi/phone.png
Executable file
After Width: | Height: | Size: 1.2 KiB |
BIN
TMessagesProj/src/main/res/drawable-mdpi/popup_fixed.9.png
Normal file → Executable file
Before Width: | Height: | Size: 961 B After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.2 KiB |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/broadcast_w.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 598 B |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/header_shadow.png
Executable file
After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 296 B |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/list_group.png
Executable file
After Width: | Height: | Size: 1.4 KiB |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/list_secret.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/phone.png
Executable file
After Width: | Height: | Size: 1.5 KiB |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/popup_fixed.9.png
Normal file → Executable file
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_w.png
Executable file
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 877 B |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/header_shadow.png
Executable file
After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 427 B |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/list_group.png
Executable file
After Width: | Height: | Size: 1.5 KiB |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/list_secret.png
Executable file
After Width: | Height: | Size: 1.2 KiB |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/phone.png
Executable file
After Width: | Height: | Size: 1.8 KiB |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/popup_fixed.9.png
Normal file → Executable file
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 2.1 KiB |
@ -1,33 +0,0 @@
|
|||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_gravity="top">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:textColor="#333333"
|
|
||||||
android:id="@+id/settings_row_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:gravity="center_vertical|right"
|
|
||||||
android:layout_gravity="top|right"/>
|
|
||||||
|
|
||||||
<org.telegram.ui.Views.IdenticonView
|
|
||||||
android:id="@+id/identicon_view"
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:layout_gravity="left|center_vertical"/>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:background="@color/divider"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="1px"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:id="@+id/settings_row_divider"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@ -1,33 +0,0 @@
|
|||||||
<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="16dp"
|
|
||||||
android:paddingRight="30dp"
|
|
||||||
android:dividerHeight="0dp"
|
|
||||||
android:divider="@null"
|
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:fastScrollEnabled="true"
|
|
||||||
android:fastScrollAlwaysVisible="true"
|
|
||||||
android:scrollbarStyle="outsideOverlay"
|
|
||||||
android:layout_gravity="top"/>
|
|
||||||
|
|
||||||
|
|
||||||
<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>
|
|
@ -15,9 +15,10 @@
|
|||||||
android:paddingTop="20dp"
|
android:paddingTop="20dp"
|
||||||
android:paddingBottom="20dp">
|
android:paddingBottom="20dp">
|
||||||
|
|
||||||
<org.telegram.ui.Views.IdenticonView
|
<ImageView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
android:scaleType="fitXY"
|
||||||
android:id="@+id/identicon_view"/>
|
android:id="@+id/identicon_view"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_gravity="top">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:textColor="#333333"
|
|
||||||
android:id="@+id/settings_row_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:layout_gravity="top"/>
|
|
||||||
|
|
||||||
<org.telegram.ui.Views.IdenticonView
|
|
||||||
android:id="@+id/identicon_view"
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:layout_gravity="right|center_vertical"/>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:background="@color/divider"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="1px"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:id="@+id/settings_row_divider"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@ -1,43 +0,0 @@
|
|||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="top"
|
|
||||||
android:background="#fafafa"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:id="@+id/listView"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:fadingEdge="none"
|
|
||||||
android:fadingEdgeLength="0dp"
|
|
||||||
android:paddingLeft="13dp"
|
|
||||||
android:paddingRight="13dp"
|
|
||||||
android:dividerHeight="0dp"
|
|
||||||
android:divider="@null"
|
|
||||||
android:scrollbars="none"
|
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:layout_gravity="top"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:background="@drawable/gray_button"
|
|
||||||
android:id="@+id/start_secret_button">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:textColor="#444444"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:drawableLeft="@drawable/bigtimer"
|
|
||||||
android:gravity="center"
|
|
||||||
android:id="@+id/start_secret_button_text"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -187,11 +187,11 @@
|
|||||||
<string name="BlockContact">Block</string>
|
<string name="BlockContact">Block</string>
|
||||||
<string name="EditContact">Edit</string>
|
<string name="EditContact">Edit</string>
|
||||||
<string name="DeleteContact">Delete</string>
|
<string name="DeleteContact">Delete</string>
|
||||||
<string name="PhoneHome">HOME</string>
|
<string name="PhoneHome">Home</string>
|
||||||
<string name="PhoneMobile">MOBILE</string>
|
<string name="PhoneMobile">Mobile</string>
|
||||||
<string name="PhoneWork">WORK</string>
|
<string name="PhoneWork">Work</string>
|
||||||
<string name="PhoneOther">OTHER</string>
|
<string name="PhoneOther">Other</string>
|
||||||
<string name="PhoneMain">MAIN</string>
|
<string name="PhoneMain">Main</string>
|
||||||
<string name="ContactInfo">Contact Info</string>
|
<string name="ContactInfo">Contact Info</string>
|
||||||
<string name="PHONE">PHONE</string>
|
<string name="PHONE">PHONE</string>
|
||||||
<string name="StartEncryptedChat">Start Secret Chat</string>
|
<string name="StartEncryptedChat">Start Secret Chat</string>
|
||||||
|