More Android L design
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
@ -47,6 +47,7 @@ public class ActionBar extends FrameLayout {
|
||||||
private ActionBarMenu menu;
|
private ActionBarMenu menu;
|
||||||
private ActionBarMenu actionMode;
|
private ActionBarMenu actionMode;
|
||||||
private View actionOverlay;
|
private View actionOverlay;
|
||||||
|
|
||||||
protected boolean isSearchFieldVisible;
|
protected boolean isSearchFieldVisible;
|
||||||
protected int itemsBackgroundResourceId;
|
protected int itemsBackgroundResourceId;
|
||||||
private boolean isBackOverlayVisible;
|
private boolean isBackOverlayVisible;
|
||||||
|
@ -69,23 +70,6 @@ public class ActionBar extends FrameLayout {
|
||||||
titleFrameLayout.setLayoutParams(layoutParams);
|
titleFrameLayout.setLayoutParams(layoutParams);
|
||||||
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
||||||
titleFrameLayout.setEnabled(false);
|
titleFrameLayout.setEnabled(false);
|
||||||
|
|
||||||
backButtonImageView = new ImageView(getContext());
|
|
||||||
titleFrameLayout.addView(backButtonImageView);
|
|
||||||
backButtonImageView.setVisibility(VISIBLE);
|
|
||||||
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
|
|
||||||
backButtonImageView.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (isSearchFieldVisible) {
|
|
||||||
closeSearchField();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (actionBarMenuOnItemClick != null) {
|
|
||||||
actionBarMenuOnItemClick.onItemClick(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void positionBackImage(int height) {
|
private void positionBackImage(int height) {
|
||||||
|
@ -139,13 +123,20 @@ public class ActionBar extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (backButtonImageView != null) {
|
||||||
x = AndroidUtilities.dp(80);
|
if (AndroidUtilities.isTablet()) {
|
||||||
|
x = AndroidUtilities.dp(80);
|
||||||
|
} else {
|
||||||
|
x = AndroidUtilities.dp(72);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
x = AndroidUtilities.dp(72);
|
if (AndroidUtilities.isTablet()) {
|
||||||
|
x = AndroidUtilities.dp(26);
|
||||||
|
} else {
|
||||||
|
x = AndroidUtilities.dp(18);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (menu != null) {
|
if (menu != null) {
|
||||||
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16));
|
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16));
|
||||||
}
|
}
|
||||||
|
@ -191,11 +182,39 @@ public class ActionBar extends FrameLayout {
|
||||||
menu.measure(width, height);
|
menu.measure(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createBackButtonImage() {
|
||||||
|
if (backButtonImageView != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
backButtonImageView = new ImageView(getContext());
|
||||||
|
titleFrameLayout.addView(backButtonImageView);
|
||||||
|
backButtonImageView.setVisibility(VISIBLE);
|
||||||
|
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
backButtonImageView.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (isSearchFieldVisible) {
|
||||||
|
closeSearchField();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (actionBarMenuOnItemClick != null) {
|
||||||
|
actionBarMenuOnItemClick.onItemClick(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void setBackButtonDrawable(Drawable drawable) {
|
public void setBackButtonDrawable(Drawable drawable) {
|
||||||
|
if (backButtonImageView == null) {
|
||||||
|
createBackButtonImage();
|
||||||
|
}
|
||||||
backButtonImageView.setImageDrawable(drawable);
|
backButtonImageView.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackButtonImage(int resource) {
|
public void setBackButtonImage(int resource) {
|
||||||
|
if (backButtonImageView == null) {
|
||||||
|
createBackButtonImage();
|
||||||
|
}
|
||||||
backButtonImageView.setImageResource(resource);
|
backButtonImageView.setImageResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +504,9 @@ public class ActionBar extends FrameLayout {
|
||||||
|
|
||||||
public void setItemsBackground(int resourceId) {
|
public void setItemsBackground(int resourceId) {
|
||||||
itemsBackgroundResourceId = resourceId;
|
itemsBackgroundResourceId = resourceId;
|
||||||
backButtonImageView.setBackgroundResource(resourceId);
|
if (backButtonImageView != null) {
|
||||||
|
backButtonImageView.setBackgroundResource(resourceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
//Thanks to https://github.com/JakeWharton/ActionBarSherlock/
|
//Thanks to https://github.com/JakeWharton/ActionBarSherlock/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013.
|
* Copyright Nikolai Kudashov, 2013.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
|
@ -6,7 +6,7 @@
|
||||||
* Copyright Nikolai Kudashov, 2013-2014.
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.telegram.ui.Views.ActionBar;
|
package org.telegram.ui.ActionBar;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
|
@ -15,12 +15,6 @@ import android.widget.BaseAdapter;
|
||||||
|
|
||||||
public class BaseFragmentAdapter extends BaseAdapter {
|
public class BaseFragmentAdapter extends BaseAdapter {
|
||||||
|
|
||||||
public void onFragmentCreate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onFragmentDestroy() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -120,7 +120,7 @@ public abstract class BaseSectionsAdapter extends BaseFragmentAdapter {
|
||||||
}
|
}
|
||||||
sectionStart = sectionEnd;
|
sectionStart = sectionEnd;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPositionInSectionForPosition(int position) {
|
public int getPositionInSectionForPosition(int position) {
|
||||||
|
@ -139,7 +139,7 @@ public abstract class BaseSectionsAdapter extends BaseFragmentAdapter {
|
||||||
}
|
}
|
||||||
sectionStart = sectionEnd;
|
sectionStart = sectionEnd;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int getSectionCount();
|
public abstract int getSectionCount();
|
||||||
|
|
|
@ -28,14 +28,14 @@ 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 BaseSectionsAdapter {
|
public class ContactsAdapter extends BaseSectionsAdapter {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean onlyUsers;
|
private boolean onlyUsers;
|
||||||
private boolean needPhonebook;
|
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 ContactsAdapter(Context context, boolean arg1, boolean arg2, HashMap<Integer, TLRPC.User> arg3) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
onlyUsers = arg1;
|
onlyUsers = arg1;
|
||||||
needPhonebook = arg2;
|
needPhonebook = arg2;
|
|
@ -24,26 +24,32 @@ import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.GreySectionCell;
|
import org.telegram.ui.Cells.GreySectionCell;
|
||||||
import org.telegram.ui.Cells.ProfileSearchCell;
|
import org.telegram.ui.Cells.ProfileSearchCell;
|
||||||
|
import org.telegram.ui.Cells.UserCell;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
||||||
private ArrayList<TLRPC.User> searchResult = new ArrayList<TLRPC.User>();
|
private ArrayList<TLRPC.User> searchResult = new ArrayList<TLRPC.User>();
|
||||||
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
|
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
|
||||||
private Timer searchTimer;
|
private Timer searchTimer;
|
||||||
private boolean allowUsernameSearch;
|
private boolean allowUsernameSearch;
|
||||||
|
private boolean useUserCell;
|
||||||
|
|
||||||
public ContactsActivitySearchAdapter(Context context, HashMap<Integer, TLRPC.User> arg1, boolean usernameSearch) {
|
public ContactsSearchAdapter(Context context, HashMap<Integer, TLRPC.User> arg1, boolean usernameSearch) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
ignoreUsers = arg1;
|
ignoreUsers = arg1;
|
||||||
allowUsernameSearch = usernameSearch;
|
allowUsernameSearch = usernameSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseUserCell(boolean value) {
|
||||||
|
useUserCell = value;
|
||||||
|
}
|
||||||
|
|
||||||
public void searchDialogs(final String query) {
|
public void searchDialogs(final String query) {
|
||||||
try {
|
try {
|
||||||
if (searchTimer != null) {
|
if (searchTimer != null) {
|
||||||
|
@ -202,10 +208,13 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new ProfileSearchCell(mContext);
|
if (useUserCell) {
|
||||||
|
view = new UserCell(mContext, 1);
|
||||||
|
} else {
|
||||||
|
view = new ProfileSearchCell(mContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((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;
|
||||||
|
@ -227,13 +236,16 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((ProfileSearchCell) view).setData(user, null, null, name, username);
|
if (useUserCell) {
|
||||||
|
((UserCell) view).setData(user, name, username, 0);
|
||||||
if (ignoreUsers != null) {
|
} else {
|
||||||
if (ignoreUsers.containsKey(user.id)) {
|
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
|
||||||
((ProfileSearchCell) view).drawAlpha = 0.5f;
|
if (ignoreUsers != null) {
|
||||||
} else {
|
if (ignoreUsers.containsKey(user.id)) {
|
||||||
((ProfileSearchCell) view).drawAlpha = 1.0f;
|
((ProfileSearchCell) view).drawAlpha = 0.5f;
|
||||||
|
} else {
|
||||||
|
((ProfileSearchCell) view).drawAlpha = 1.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.android.LocaleController;
|
||||||
|
import org.telegram.messenger.FileLog;
|
||||||
|
import org.telegram.ui.ApplicationLoader;
|
||||||
|
import org.telegram.ui.Cells.DividerCell;
|
||||||
|
import org.telegram.ui.Cells.LetterSectionCell;
|
||||||
|
import org.telegram.ui.Cells.TextSettingsCell;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class CountryAdapter extends BaseSectionsAdapter {
|
||||||
|
|
||||||
|
public static class Country {
|
||||||
|
public String name;
|
||||||
|
public String code;
|
||||||
|
public String shortname;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private HashMap<String, ArrayList<Country>> countries = new HashMap<String, ArrayList<Country>>();
|
||||||
|
private ArrayList<String> sortedCountries = new ArrayList<String>();
|
||||||
|
|
||||||
|
public CountryAdapter(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
|
||||||
|
try {
|
||||||
|
InputStream stream = ApplicationLoader.applicationContext.getResources().getAssets().open("countries.txt");
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
String[] args = line.split(";");
|
||||||
|
Country c = new Country();
|
||||||
|
c.name = args[2];
|
||||||
|
c.code = args[0];
|
||||||
|
c.shortname = args[1];
|
||||||
|
String n = c.name.substring(0, 1).toUpperCase();
|
||||||
|
ArrayList<Country> arr = countries.get(n);
|
||||||
|
if (arr == null) {
|
||||||
|
arr = new ArrayList<Country>();
|
||||||
|
countries.put(n, arr);
|
||||||
|
sortedCountries.add(n);
|
||||||
|
}
|
||||||
|
arr.add(c);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
stream.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(sortedCountries, new Comparator<String>() {
|
||||||
|
@Override
|
||||||
|
public int compare(String lhs, String rhs) {
|
||||||
|
return lhs.compareTo(rhs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (ArrayList<Country> arr : countries.values()) {
|
||||||
|
Collections.sort(arr, new Comparator<Country>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Country country, Country country2) {
|
||||||
|
return country.name.compareTo(country2.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, ArrayList<Country>> getCountries() {
|
||||||
|
return countries;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Country getItem(int section, int position) {
|
||||||
|
if (section < 0 || section >= sortedCountries.size()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ArrayList<Country> arr = countries.get(sortedCountries.get(section));
|
||||||
|
if (position < 0 || position >= arr.size()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return arr.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRowEnabled(int section, int row) {
|
||||||
|
ArrayList<Country> arr = countries.get(sortedCountries.get(section));
|
||||||
|
return row < arr.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSectionCount() {
|
||||||
|
return sortedCountries.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCountForSection(int section) {
|
||||||
|
int count = countries.get(sortedCountries.get(section)).size();
|
||||||
|
if (section != sortedCountries.size() - 1) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new LetterSectionCell(mContext);
|
||||||
|
((LetterSectionCell) convertView).setCellHeight(AndroidUtilities.dp(48));
|
||||||
|
}
|
||||||
|
((LetterSectionCell) convertView).setLetter(sortedCountries.get(section).toUpperCase());
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
|
||||||
|
int type = getItemViewType(section, position);
|
||||||
|
if (type == 1) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new DividerCell(mContext);
|
||||||
|
convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 24 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 24), 0);
|
||||||
|
}
|
||||||
|
} else if (type == 0) {
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = new TextSettingsCell(mContext);
|
||||||
|
convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 16 : 54), 0, AndroidUtilities.dp(LocaleController.isRTL ? 54 : 16), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Country> arr = countries.get(sortedCountries.get(section));
|
||||||
|
Country c = arr.get(position);
|
||||||
|
((TextSettingsCell) convertView).setTextAndValue(c.name, "+" + c.code, false);
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int section, int position) {
|
||||||
|
ArrayList<Country> arr = countries.get(sortedCountries.get(section));
|
||||||
|
return position < arr.size() ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getViewTypeCount() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.7.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.messenger.FileLog;
|
||||||
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Adapters.CountryAdapter.Country;
|
||||||
|
import org.telegram.ui.Cells.TextSettingsCell;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
public class CountrySearchAdapter extends BaseFragmentAdapter {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private Timer searchTimer;
|
||||||
|
private ArrayList<CountryAdapter.Country> searchResult;
|
||||||
|
private HashMap<String, ArrayList<Country>> countries;
|
||||||
|
|
||||||
|
public CountrySearchAdapter(Context context, HashMap<String, ArrayList<Country>> countries) {
|
||||||
|
mContext = context;
|
||||||
|
this.countries = countries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void search(final String query) {
|
||||||
|
if (query == null) {
|
||||||
|
searchResult = null;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
if (searchTimer != null) {
|
||||||
|
searchTimer.cancel();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
searchTimer = new Timer();
|
||||||
|
searchTimer.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
searchTimer.cancel();
|
||||||
|
searchTimer = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
processSearch(query);
|
||||||
|
}
|
||||||
|
}, 100, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processSearch(final String query) {
|
||||||
|
Utilities.searchQueue.postRunnable(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
String q = query.trim().toLowerCase();
|
||||||
|
if (q.length() == 0) {
|
||||||
|
updateSearchResults(new ArrayList<Country>());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
ArrayList<Country> resultArray = new ArrayList<Country>();
|
||||||
|
|
||||||
|
String n = query.substring(0, 1);
|
||||||
|
ArrayList<Country> arr = countries.get(n.toUpperCase());
|
||||||
|
if (arr != null) {
|
||||||
|
for (Country c : arr) {
|
||||||
|
if (c.name.toLowerCase().startsWith(query)) {
|
||||||
|
resultArray.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSearchResults(resultArray);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSearchResults(final ArrayList<Country> arrCounties) {
|
||||||
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
searchResult = arrCounties;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areAllItemsEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(int i) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
if (searchResult == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return searchResult.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Country getItem(int i) {
|
||||||
|
if (i < 0 || i >= searchResult.size()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return searchResult.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int i) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasStableIds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
|
if (view == null) {
|
||||||
|
view = new TextSettingsCell(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Country c = searchResult.get(i);
|
||||||
|
((TextSettingsCell) view).setTextAndValue(c.name, "+" + c.code, i != searchResult.size() - 1);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int i) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getViewTypeCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return searchResult == null || searchResult.size() == 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,13 +20,13 @@ import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.ui.Cells.DialogCell;
|
import org.telegram.ui.Cells.DialogCell;
|
||||||
|
|
||||||
public class MessagesActivityAdapter extends BaseFragmentAdapter {
|
public class DialogsAdapter extends BaseFragmentAdapter {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean serverOnly;
|
private boolean serverOnly;
|
||||||
private long openedDialogId;
|
private long openedDialogId;
|
||||||
|
|
||||||
public MessagesActivityAdapter(Context context, boolean onlyFromServer) {
|
public DialogsAdapter(Context context, boolean onlyFromServer) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
serverOnly = onlyFromServer;
|
serverOnly = onlyFromServer;
|
||||||
}
|
}
|
|
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Timer searchTimer;
|
private Timer searchTimer;
|
||||||
private ArrayList<TLObject> searchResult = new ArrayList<TLObject>();
|
private ArrayList<TLObject> searchResult = new ArrayList<TLObject>();
|
||||||
|
@ -53,7 +53,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
||||||
public abstract void searchStateChanged(boolean searching);
|
public abstract void searchStateChanged(boolean searching);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagesActivitySearchAdapter(Context context) {
|
public DialogsSearchAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ package org.telegram.ui.Animation;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public final class ObjectAnimator10 extends ValueAnimator {
|
public final class ObjectAnimator10 extends ValueAnimator {
|
||||||
|
|
|
@ -33,11 +33,11 @@ import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Cells.TextInfoCell;
|
import org.telegram.ui.Cells.TextInfoCell;
|
||||||
import org.telegram.ui.Cells.UserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class SettingsBlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
|
public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private ListAdapter listViewAdapter;
|
private ListAdapter listViewAdapter;
|
||||||
private FrameLayout progressView;
|
private FrameLayout progressView;
|
||||||
|
@ -79,7 +79,7 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
||||||
args.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("destroyAfterSelect", 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(BlockedUsersActivity.this);
|
||||||
presentFragment(fragment);
|
presentFragment(fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -109,7 +109,7 @@ public class DialogCell extends BaseCell {
|
||||||
if (namePaint == null) {
|
if (namePaint == null) {
|
||||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
namePaint.setTextSize(AndroidUtilities.dp(17));
|
namePaint.setTextSize(AndroidUtilities.dp(17));
|
||||||
namePaint.setColor(0xff222222);
|
namePaint.setColor(0xff212121);
|
||||||
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
|
||||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
|
|
@ -40,4 +40,8 @@ public class LetterSectionCell extends FrameLayout {
|
||||||
public void setLetter(String letter) {
|
public void setLetter(String letter) {
|
||||||
textView.setText(letter.toUpperCase());
|
textView.setText(letter.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCellHeight(int height) {
|
||||||
|
setLayoutParams(new ViewGroup.LayoutParams(AndroidUtilities.dp(54), height));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class ProfileSearchCell extends BaseCell {
|
||||||
if (namePaint == null) {
|
if (namePaint == null) {
|
||||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
namePaint.setTextSize(AndroidUtilities.dp(17));
|
namePaint.setTextSize(AndroidUtilities.dp(17));
|
||||||
namePaint.setColor(0xff222222);
|
namePaint.setColor(0xff212121);
|
||||||
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
|
||||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
|
|
@ -11,6 +11,7 @@ package org.telegram.ui.Cells;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
@ -41,10 +42,11 @@ public class TextSettingsCell extends FrameLayout {
|
||||||
textView.setLines(1);
|
textView.setLines(1);
|
||||||
textView.setMaxLines(1);
|
textView.setMaxLines(1);
|
||||||
textView.setSingleLine(true);
|
textView.setSingleLine(true);
|
||||||
|
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||||
addView(textView);
|
addView(textView);
|
||||||
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.leftMargin = AndroidUtilities.dp(17);
|
layoutParams.leftMargin = AndroidUtilities.dp(17);
|
||||||
layoutParams.rightMargin = AndroidUtilities.dp(17);
|
layoutParams.rightMargin = AndroidUtilities.dp(17);
|
||||||
|
@ -57,6 +59,7 @@ public class TextSettingsCell extends FrameLayout {
|
||||||
valueTextView.setLines(1);
|
valueTextView.setLines(1);
|
||||||
valueTextView.setMaxLines(1);
|
valueTextView.setMaxLines(1);
|
||||||
valueTextView.setSingleLine(true);
|
valueTextView.setSingleLine(true);
|
||||||
|
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
|
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
|
||||||
addView(valueTextView);
|
addView(valueTextView);
|
||||||
layoutParams = (LayoutParams) valueTextView.getLayoutParams();
|
layoutParams = (LayoutParams) valueTextView.getLayoutParams();
|
||||||
|
@ -70,7 +73,17 @@ public class TextSettingsCell extends FrameLayout {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(48) + (needDivider ? 1 : 0));
|
||||||
|
|
||||||
|
int availableWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - AndroidUtilities.dp(34);
|
||||||
|
int width = availableWidth / 2;
|
||||||
|
if (valueTextView.getVisibility() == VISIBLE) {
|
||||||
|
valueTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
||||||
|
width = availableWidth - valueTextView.getMeasuredWidth() - AndroidUtilities.dp(8);
|
||||||
|
} else {
|
||||||
|
width = availableWidth;
|
||||||
|
}
|
||||||
|
textView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextColor(int color) {
|
public void setTextColor(int color) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -33,6 +34,7 @@ public class UserCell extends FrameLayout {
|
||||||
private TextView nameTextView;
|
private TextView nameTextView;
|
||||||
private TextView statusTextView;
|
private TextView statusTextView;
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
|
private CheckBox checkBox;
|
||||||
|
|
||||||
private AvatarDrawable avatarDrawable;
|
private AvatarDrawable avatarDrawable;
|
||||||
private TLRPC.User currentUser = null;
|
private TLRPC.User currentUser = null;
|
||||||
|
@ -65,7 +67,7 @@ public class UserCell extends FrameLayout {
|
||||||
avatarDrawable = new AvatarDrawable();
|
avatarDrawable = new AvatarDrawable();
|
||||||
|
|
||||||
nameTextView = new TextView(context);
|
nameTextView = new TextView(context);
|
||||||
nameTextView.setTextColor(0xff000000);
|
nameTextView.setTextColor(0xff212121);
|
||||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
|
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
|
||||||
nameTextView.setLines(1);
|
nameTextView.setLines(1);
|
||||||
nameTextView.setMaxLines(1);
|
nameTextView.setMaxLines(1);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -29,16 +28,20 @@ import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
|
public class ChangeChatNameActivity extends BaseFragment {
|
||||||
|
|
||||||
public class ChatProfileChangeNameActivity extends BaseFragment {
|
|
||||||
private EditText firstNameField;
|
private EditText firstNameField;
|
||||||
private View headerLabelView;
|
private View headerLabelView;
|
||||||
private int chat_id;
|
private int chat_id;
|
||||||
private View doneButton;
|
private View doneButton;
|
||||||
|
|
||||||
public ChatProfileChangeNameActivity(Bundle args) {
|
private final static int done_button = 1;
|
||||||
|
|
||||||
|
public ChangeChatNameActivity(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,40 +55,34 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
|
||||||
|
|
||||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
|
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
|
||||||
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onItemClick(int id) {
|
||||||
finishFragment();
|
if (id == -1) {
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = actionBar.findViewById(R.id.done_button);
|
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (firstNameField.getText().length() != 0) {
|
|
||||||
saveName();
|
|
||||||
finishFragment();
|
finishFragment();
|
||||||
|
} else if (id == done_button) {
|
||||||
|
if (firstNameField.getText().length() != 0) {
|
||||||
|
saveName();
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
|
||||||
|
|
||||||
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
|
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
|
||||||
|
|
||||||
fragmentView = new LinearLayout(inflater.getContext());
|
fragmentView = new LinearLayout(inflater.getContext());
|
||||||
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
fragmentView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), 0);
|
fragmentView.setPadding(0, AndroidUtilities.dp(8), 0, 0);
|
||||||
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
|
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
SettingsSectionLayout settingsSectionLayout = new SettingsSectionLayout(inflater.getContext());
|
|
||||||
((LinearLayout) fragmentView).addView(settingsSectionLayout);
|
|
||||||
|
|
||||||
firstNameField = new EditText(inflater.getContext());
|
firstNameField = new EditText(inflater.getContext());
|
||||||
firstNameField.setText(currentChat.title);
|
firstNameField.setText(currentChat.title);
|
||||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
|
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
|
||||||
|
@ -114,15 +111,15 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
||||||
((LinearLayout) fragmentView).addView(firstNameField);
|
((LinearLayout) fragmentView).addView(firstNameField);
|
||||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
|
||||||
layoutParams.topMargin = AndroidUtilities.dp(15);
|
layoutParams.topMargin = AndroidUtilities.dp(15);
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(16);
|
||||||
|
layoutParams.rightMargin = AndroidUtilities.dp(16);
|
||||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||||
firstNameField.setLayoutParams(layoutParams);
|
firstNameField.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
if (chat_id > 0) {
|
if (chat_id > 0) {
|
||||||
settingsSectionLayout.setText(LocaleController.getString("EnterGroupNameTitle", R.string.EnterGroupNameTitle));
|
|
||||||
firstNameField.setHint(LocaleController.getString("GroupName", R.string.GroupName));
|
firstNameField.setHint(LocaleController.getString("GroupName", R.string.GroupName));
|
||||||
} else {
|
} else {
|
||||||
settingsSectionLayout.setText(LocaleController.getString("EnterListName", R.string.EnterListName).toUpperCase());
|
|
||||||
firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
|
firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
|
||||||
}
|
}
|
||||||
firstNameField.setSelection(firstNameField.length());
|
firstNameField.setSelection(firstNameField.length());
|
|
@ -18,7 +18,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -33,40 +32,44 @@ import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
import org.telegram.ui.Views.SettingsSectionLayout;
|
||||||
|
|
||||||
public class SettingsChangeNameActivity extends BaseFragment {
|
public class ChangeNameActivity extends BaseFragment {
|
||||||
|
|
||||||
private EditText firstNameField;
|
private EditText firstNameField;
|
||||||
private EditText lastNameField;
|
private EditText lastNameField;
|
||||||
private View headerLabelView;
|
private View headerLabelView;
|
||||||
private View doneButton;
|
private View doneButton;
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
|
||||||
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onItemClick(int id) {
|
||||||
finishFragment();
|
if (id == -1) {
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = actionBar.findViewById(R.id.done_button);
|
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (firstNameField.getText().length() != 0) {
|
|
||||||
saveName();
|
|
||||||
finishFragment();
|
finishFragment();
|
||||||
|
} else if (id == done_button) {
|
||||||
|
if (firstNameField.getText().length() != 0) {
|
||||||
|
saveName();
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
|
||||||
|
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
|
||||||
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
||||||
if (user == null) {
|
if (user == null) {
|
|
@ -24,7 +24,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -41,12 +40,14 @@ import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.TLObject;
|
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.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
import org.telegram.ui.Views.SettingsSectionLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SettingsChangeUsernameActivity extends BaseFragment {
|
public class ChangeUsernameActivity extends BaseFragment {
|
||||||
|
|
||||||
private EditText firstNameField;
|
private EditText firstNameField;
|
||||||
private View doneButton;
|
private View doneButton;
|
||||||
|
@ -56,28 +57,27 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
||||||
private Runnable checkRunnable = null;
|
private Runnable checkRunnable = null;
|
||||||
private boolean lastNameAvailable = false;
|
private boolean lastNameAvailable = false;
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
|
||||||
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onItemClick(int id) {
|
||||||
finishFragment();
|
if (id == -1) {
|
||||||
}
|
finishFragment();
|
||||||
});
|
} else if (id == done_button) {
|
||||||
doneButton = actionBar.findViewById(R.id.done_button);
|
saveName();
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
}
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
saveName();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
|
||||||
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
||||||
if (user == null) {
|
if (user == null) {
|
|
@ -71,12 +71,12 @@ import org.telegram.ui.Cells.ChatBaseCell;
|
||||||
import org.telegram.ui.Cells.ChatContactCell;
|
import org.telegram.ui.Cells.ChatContactCell;
|
||||||
import org.telegram.ui.Cells.ChatMediaCell;
|
import org.telegram.ui.Cells.ChatMediaCell;
|
||||||
import org.telegram.ui.Cells.ChatMessageCell;
|
import org.telegram.ui.Cells.ChatMessageCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.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.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.ChatActivityEnterView;
|
import org.telegram.ui.Views.ChatActivityEnterView;
|
||||||
import org.telegram.android.ImageReceiver;
|
import org.telegram.android.ImageReceiver;
|
||||||
import org.telegram.ui.Views.LayoutListView;
|
import org.telegram.ui.Views.LayoutListView;
|
||||||
|
@ -2364,6 +2364,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", currentUser.id);
|
args.putInt("user_id", currentUser.id);
|
||||||
|
args.putBoolean("addContact", true);
|
||||||
presentFragment(new ContactAddActivity(args));
|
presentFragment(new ContactAddActivity(args));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3292,6 +3293,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", messageObject.messageOwner.media.user_id);
|
args.putInt("user_id", messageObject.messageOwner.media.user_id);
|
||||||
args.putString("phone", messageObject.messageOwner.media.phone_number);
|
args.putString("phone", messageObject.messageOwner.media.phone_number);
|
||||||
|
args.putBoolean("addContact", true);
|
||||||
presentFragment(new ContactAddActivity(args));
|
presentFragment(new ContactAddActivity(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -29,13 +28,14 @@ import org.telegram.messenger.TLRPC;
|
||||||
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.ActionBar.ActionBar;
|
||||||
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
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.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
private int user_id;
|
|
||||||
private String phone = null;
|
|
||||||
private View doneButton;
|
private View doneButton;
|
||||||
private EditText firstNameField;
|
private EditText firstNameField;
|
||||||
private EditText lastNameField;
|
private EditText lastNameField;
|
||||||
|
@ -43,6 +43,12 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||||
private TextView onlineText;
|
private TextView onlineText;
|
||||||
private TextView phoneText;
|
private TextView phoneText;
|
||||||
|
|
||||||
|
private int user_id;
|
||||||
|
private boolean addContact;
|
||||||
|
private String phone = null;
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
public ContactAddActivity(Bundle args) {
|
public ContactAddActivity(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +58,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||||
user_id = getArguments().getInt("user_id", 0);
|
user_id = getArguments().getInt("user_id", 0);
|
||||||
phone = getArguments().getString("phone");
|
phone = getArguments().getString("phone");
|
||||||
|
addContact = getArguments().getBoolean("addContact", false);
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
return user != null && super.onFragmentCreate();
|
return user != null && super.onFragmentCreate();
|
||||||
}
|
}
|
||||||
|
@ -65,32 +72,33 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
if (addContact) {
|
||||||
|
actionBar.setTitle(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
|
||||||
|
} else {
|
||||||
|
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
|
||||||
|
}
|
||||||
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onItemClick(int id) {
|
||||||
finishFragment();
|
if (id == -1) {
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = actionBar.findViewById(R.id.done_button);
|
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (firstNameField.getText().length() != 0) {
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
|
||||||
user.first_name = firstNameField.getText().toString();
|
|
||||||
user.last_name = lastNameField.getText().toString();
|
|
||||||
ContactsController.getInstance().addContact(user);
|
|
||||||
finishFragment();
|
finishFragment();
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
} else if (id == done_button) {
|
||||||
|
if (firstNameField.getText().length() != 0) {
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
|
user.first_name = firstNameField.getText().toString();
|
||||||
|
user.last_name = lastNameField.getText().toString();
|
||||||
|
ContactsController.getInstance().addContact(user);
|
||||||
|
finishFragment();
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,13 @@ import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
import org.telegram.ui.Adapters.ContactsAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
import org.telegram.ui.Adapters.ContactsSearchAdapter;
|
||||||
import org.telegram.ui.Cells.UserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SectionsListView;
|
import org.telegram.ui.Views.SectionsListView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -56,7 +56,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
private BaseSectionsAdapter listViewAdapter;
|
private BaseSectionsAdapter listViewAdapter;
|
||||||
private TextView emptyTextView;
|
private TextView emptyTextView;
|
||||||
private SectionsListView listView;
|
private SectionsListView listView;
|
||||||
private ContactsActivitySearchAdapter searchListViewAdapter;
|
private ContactsSearchAdapter searchListViewAdapter;
|
||||||
|
|
||||||
private boolean searchWas;
|
private boolean searchWas;
|
||||||
private boolean searching;
|
private boolean searching;
|
||||||
|
@ -150,7 +150,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
listView.setFastScrollEnabled(true);
|
listView.setFastScrollEnabled(true);
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,8 +178,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
|
searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
|
||||||
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers);
|
listViewAdapter = new ContactsAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers);
|
||||||
|
|
||||||
fragmentView = new FrameLayout(getParentActivity());
|
fragmentView = new FrameLayout(getParentActivity());
|
||||||
|
|
||||||
|
|
|
@ -8,40 +8,30 @@
|
||||||
|
|
||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.os.Build;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.messenger.FileLog;
|
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.ui.Adapters.CountryAdapter;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.CountryAdapter.Country;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.Adapters.CountrySearchAdapter;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
import org.telegram.ui.Views.SectionsListView;
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class CountrySelectActivity extends BaseFragment {
|
public class CountrySelectActivity extends BaseFragment {
|
||||||
|
|
||||||
|
@ -49,68 +39,18 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
public abstract void didSelectCountry(String name);
|
public abstract void didSelectCountry(String name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SectionedBaseAdapter listViewAdapter;
|
private SectionsListView listView;
|
||||||
private PinnedHeaderListView listView;
|
private TextView emptyTextView;
|
||||||
|
private CountryAdapter listViewAdapter;
|
||||||
|
private CountrySearchAdapter searchListViewAdapter;
|
||||||
|
|
||||||
private boolean searchWas;
|
private boolean searchWas;
|
||||||
private boolean searching;
|
private boolean searching;
|
||||||
private BaseAdapter searchListViewAdapter;
|
|
||||||
private TextView emptyTextView;
|
|
||||||
private HashMap<String, ArrayList<Country>> countries = new HashMap<String, ArrayList<Country>>();
|
|
||||||
private ArrayList<String> sortedCountries = new ArrayList<String>();
|
|
||||||
private CountrySelectActivityDelegate delegate;
|
private CountrySelectActivityDelegate delegate;
|
||||||
|
|
||||||
private Timer searchTimer;
|
|
||||||
public ArrayList<Country> searchResult;
|
|
||||||
|
|
||||||
public static class Country {
|
|
||||||
public String name;
|
|
||||||
public String code;
|
|
||||||
public String shortname;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
try {
|
|
||||||
InputStream stream = ApplicationLoader.applicationContext.getResources().getAssets().open("countries.txt");
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
String[] args = line.split(";");
|
|
||||||
Country c = new Country();
|
|
||||||
c.name = args[2];
|
|
||||||
c.code = args[0];
|
|
||||||
c.shortname = args[1];
|
|
||||||
String n = c.name.substring(0, 1).toUpperCase();
|
|
||||||
ArrayList<Country> arr = countries.get(n);
|
|
||||||
if (arr == null) {
|
|
||||||
arr = new ArrayList<Country>();
|
|
||||||
countries.put(n, arr);
|
|
||||||
sortedCountries.add(n);
|
|
||||||
}
|
|
||||||
arr.add(c);
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
stream.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(sortedCountries, new Comparator<String>() {
|
|
||||||
@Override
|
|
||||||
public int compare(String lhs, String rhs) {
|
|
||||||
return lhs.compareTo(rhs);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (ArrayList<Country> arr : countries.values()) {
|
|
||||||
Collections.sort(arr, new Comparator<Country>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Country country, Country country2) {
|
|
||||||
return country.name.compareTo(country2.name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onFragmentCreate();
|
return super.onFragmentCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +60,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, final ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
|
@ -144,16 +84,11 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public void onSearchCollapse() {
|
||||||
search(null);
|
searchListViewAdapter.search(null);
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
ViewGroup group = (ViewGroup) listView.getParent();
|
ViewGroup group = (ViewGroup) listView.getParent();
|
||||||
listView.setAdapter(listViewAdapter);
|
listView.setAdapter(listViewAdapter);
|
||||||
if (!LocaleController.isRTL) {
|
|
||||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(30), listView.getPaddingBottom());
|
|
||||||
} else {
|
|
||||||
listView.setPadding(AndroidUtilities.dp(30), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
|
||||||
}
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
listView.setFastScrollAlwaysVisible(true);
|
listView.setFastScrollAlwaysVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -166,11 +101,10 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(EditText editText) {
|
public void onTextChanged(EditText editText) {
|
||||||
String text = editText.getText().toString();
|
String text = editText.getText().toString();
|
||||||
search(text);
|
searchListViewAdapter.search(text);
|
||||||
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);
|
||||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
listView.setFastScrollAlwaysVisible(false);
|
listView.setFastScrollAlwaysVisible(false);
|
||||||
|
@ -179,7 +113,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
listView.setVerticalScrollBarEnabled(true);
|
listView.setVerticalScrollBarEnabled(true);
|
||||||
}
|
}
|
||||||
if (emptyTextView != null) {
|
if (emptyTextView != null) {
|
||||||
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,51 +122,69 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.country_select_layout, container, false);
|
listViewAdapter = new CountryAdapter(getParentActivity());
|
||||||
|
searchListViewAdapter = new CountrySearchAdapter(getParentActivity(), listViewAdapter.getCountries());
|
||||||
|
|
||||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
fragmentView = new FrameLayout(getParentActivity());
|
||||||
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
|
||||||
|
|
||||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
emptyTextView = new TextView(getParentActivity());
|
||||||
listView.setEmptyView(emptyTextView);
|
emptyTextView.setTextColor(0xff808080);
|
||||||
|
emptyTextView.setTextSize(24);
|
||||||
|
emptyTextView.setGravity(Gravity.CENTER);
|
||||||
|
emptyTextView.setVisibility(View.INVISIBLE);
|
||||||
|
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||||
|
((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);
|
|
||||||
|
|
||||||
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
|
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);
|
||||||
|
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) {
|
||||||
if (i < 0) {
|
Country country = null;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (searching && searchWas) {
|
if (searching && searchWas) {
|
||||||
if (i >= 0 && i < searchResult.size()) {
|
country = searchListViewAdapter.getItem(i);
|
||||||
Country c = searchResult.get(i);
|
|
||||||
if (delegate != null) {
|
|
||||||
delegate.didSelectCountry(c.name);
|
|
||||||
}
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int section = listViewAdapter.getSectionForPosition(i);
|
int section = listViewAdapter.getSectionForPosition(i);
|
||||||
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
||||||
if (section >= 0 && section < sortedCountries.size()) {
|
if (row < 0 || section < 0) {
|
||||||
String n = sortedCountries.get(section);
|
return;
|
||||||
ArrayList<Country> arr = countries.get(n);
|
|
||||||
if (row >= 0 && row < arr.size()) {
|
|
||||||
Country c = arr.get(row);
|
|
||||||
if (delegate != null) {
|
|
||||||
delegate.didSelectCountry(c.name);
|
|
||||||
}
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
country = listViewAdapter.getItem(section, row);
|
||||||
}
|
}
|
||||||
|
if (i < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (country != null && delegate != null) {
|
||||||
|
delegate.didSelectCountry(country.name);
|
||||||
|
}
|
||||||
|
finishFragment();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -265,234 +217,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void search(final String query) {
|
|
||||||
if (query == null) {
|
|
||||||
searchResult = null;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
if (searchTimer != null) {
|
|
||||||
searchTimer.cancel();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
searchTimer = new Timer();
|
|
||||||
searchTimer.schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
searchTimer.cancel();
|
|
||||||
searchTimer = null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
processSearch(query);
|
|
||||||
}
|
|
||||||
}, 100, 300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processSearch(final String query) {
|
|
||||||
Utilities.searchQueue.postRunnable(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
String q = query.trim().toLowerCase();
|
|
||||||
if (q.length() == 0) {
|
|
||||||
updateSearchResults(new ArrayList<Country>());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
ArrayList<Country> resultArray = new ArrayList<Country>();
|
|
||||||
|
|
||||||
String n = query.substring(0, 1);
|
|
||||||
ArrayList<Country> arr = countries.get(n.toUpperCase());
|
|
||||||
if (arr != null) {
|
|
||||||
for (Country c : arr) {
|
|
||||||
if (c.name.toLowerCase().startsWith(query)) {
|
|
||||||
resultArray.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSearchResults(resultArray);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCountrySelectActivityDelegate(CountrySelectActivityDelegate delegate) {
|
public void setCountrySelectActivityDelegate(CountrySelectActivityDelegate delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSearchResults(final ArrayList<Country> arrCounties) {
|
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
searchResult = arrCounties;
|
|
||||||
searchListViewAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SearchAdapter extends BaseFragmentAdapter {
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
public SearchAdapter(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean areAllItemsEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled(int i) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
if (searchResult == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return searchResult.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getItem(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int i) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasStableIds() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
|
||||||
if (view == null) {
|
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
view = li.inflate(R.layout.country_row_layout, viewGroup, false);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
|
|
||||||
Country c = searchResult.get(i);
|
|
||||||
textView.setText(c.name);
|
|
||||||
detailTextView.setText("+" + c.code);
|
|
||||||
if (i == searchResult.size() - 1) {
|
|
||||||
divider.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int i) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return searchResult == null || searchResult.size() == 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ListAdapter extends SectionedBaseAdapter {
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
public ListAdapter(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getItem(int section, int position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int section, int position) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionCount() {
|
|
||||||
return sortedCountries.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCountForSection(int section) {
|
|
||||||
String n = sortedCountries.get(section);
|
|
||||||
ArrayList<Country> arr = countries.get(n);
|
|
||||||
return arr.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
|
|
||||||
if (convertView == null) {
|
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
convertView = li.inflate(R.layout.country_row_layout, parent, false);
|
|
||||||
}
|
|
||||||
TextView textView = (TextView)convertView.findViewById(R.id.settings_row_text);
|
|
||||||
TextView detailTextView = (TextView)convertView.findViewById(R.id.settings_row_text_detail);
|
|
||||||
View divider = convertView.findViewById(R.id.settings_row_divider);
|
|
||||||
|
|
||||||
String n = sortedCountries.get(section);
|
|
||||||
ArrayList<Country> arr = countries.get(n);
|
|
||||||
Country c = arr.get(position);
|
|
||||||
textView.setText(c.name);
|
|
||||||
detailTextView.setText("+" + c.code);
|
|
||||||
if (position == arr.size() - 1) {
|
|
||||||
divider.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int section, int position) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionHeaderViewType(int section) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionHeaderViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = new SettingsSectionLayout(mContext);
|
|
||||||
convertView.setBackgroundColor(0xfffafafa);
|
|
||||||
}
|
|
||||||
((SettingsSectionLayout) convertView).setText(sortedCountries.get(section).toUpperCase());
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,11 @@ import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
|
@ -28,6 +29,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -46,11 +48,11 @@ 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.BaseSectionsAdapter;
|
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
import org.telegram.ui.Adapters.ContactsAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
import org.telegram.ui.Adapters.ContactsSearchAdapter;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SectionsListView;
|
import org.telegram.ui.Views.SectionsListView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -87,7 +89,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
private TextView emptyTextView;
|
private TextView emptyTextView;
|
||||||
private EditText userSelectEditText;
|
private EditText userSelectEditText;
|
||||||
private SectionsListView listView;
|
private SectionsListView listView;
|
||||||
private ContactsActivitySearchAdapter searchListViewAdapter;
|
private ContactsSearchAdapter searchListViewAdapter;
|
||||||
|
|
||||||
private int beforeChangeIndex;
|
private int beforeChangeIndex;
|
||||||
private int maxCount = 200;
|
private int maxCount = 200;
|
||||||
|
@ -160,85 +162,17 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
|
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
|
||||||
doneTextView.setText(LocaleController.getString("Next", R.string.Next));
|
doneTextView.setText(LocaleController.getString("Next", R.string.Next));
|
||||||
|
|
||||||
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), null, false);
|
searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
|
||||||
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), true, false, null);
|
listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
|
||||||
|
searchListViewAdapter.setUseUserCell(true);
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/top_layout"
|
|
||||||
android:layout_gravity="top">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:textColorHint="#a6a6a6"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:minHeight="52dp"
|
|
||||||
android:gravity="right|center_vertical"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:paddingTop="3dp"
|
|
||||||
android:layout_marginTop="0dp"
|
|
||||||
android:inputType="textFilter|textNoSuggestions|textMultiLine"
|
|
||||||
android:imeOptions="flagNoExtractUi"
|
|
||||||
android:textCursorDrawable="@null"
|
|
||||||
android:textColor="#000000"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
|
|
||||||
------------RTL---------- END
|
|
||||||
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:textColorHint="#a6a6a6"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:minHeight="52dp"
|
|
||||||
android:gravity="left|center_vertical"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:paddingTop="3dp"
|
|
||||||
android:layout_marginTop="0dp"
|
|
||||||
android:inputType="textFilter|textNoSuggestions|textMultiLine"
|
|
||||||
android:imeOptions="flagNoExtractUi"
|
|
||||||
android:textCursorDrawable="@null"
|
|
||||||
android:textColor="#000000"/>
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
fragmentView = new LinearLayout(getParentActivity());
|
fragmentView = new LinearLayout(getParentActivity());
|
||||||
LinearLayout linearLayout = (LinearLayout) fragmentView;
|
LinearLayout linearLayout = (LinearLayout) fragmentView;
|
||||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
emptyTextView = new TextView(getParentActivity());
|
|
||||||
emptyTextView.setTextColor(0xff808080);
|
|
||||||
emptyTextView.setTextSize(24);
|
|
||||||
emptyTextView.setGravity(Gravity.CENTER);
|
|
||||||
emptyTextView.setVisibility(View.INVISIBLE);
|
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
|
||||||
linearLayout.addView(emptyTextView);
|
|
||||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
|
|
||||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
|
||||||
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
|
||||||
layoutParams.gravity = Gravity.TOP;
|
|
||||||
emptyTextView.setLayoutParams(layoutParams);
|
|
||||||
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
FrameLayout frameLayout = new FrameLayout(getParentActivity());
|
FrameLayout frameLayout = new FrameLayout(getParentActivity());
|
||||||
linearLayout.addView(frameLayout);
|
linearLayout.addView(frameLayout);
|
||||||
layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.gravity = Gravity.TOP;
|
layoutParams.gravity = Gravity.TOP;
|
||||||
|
@ -246,7 +180,23 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
|
|
||||||
userSelectEditText = new EditText(getParentActivity());
|
userSelectEditText = new EditText(getParentActivity());
|
||||||
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||||
|
userSelectEditText.setHintTextColor(0xffa6a6a6);
|
||||||
|
userSelectEditText.setTextColor(0xff000000);
|
||||||
|
userSelectEditText.setMinimumHeight(AndroidUtilities.dp(52));
|
||||||
|
userSelectEditText.setMaxLines(2);
|
||||||
|
userSelectEditText.setPadding(userSelectEditText.getPaddingLeft(), AndroidUtilities.dp(3), userSelectEditText.getPaddingRight(), userSelectEditText.getPaddingBottom());
|
||||||
|
userSelectEditText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||||
|
userSelectEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
|
userSelectEditText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||||
|
AndroidUtilities.clearCursorDrawable(userSelectEditText);
|
||||||
frameLayout.addView(userSelectEditText);
|
frameLayout.addView(userSelectEditText);
|
||||||
|
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams();
|
||||||
|
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams1.leftMargin = AndroidUtilities.dp(5);
|
||||||
|
layoutParams1.rightMargin = AndroidUtilities.dp(5);
|
||||||
|
layoutParams1.gravity = Gravity.TOP;
|
||||||
|
userSelectEditText.setLayoutParams(layoutParams1);
|
||||||
|
|
||||||
userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
|
userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
|
@ -301,24 +251,59 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
if (search) {
|
if (search) {
|
||||||
String text = userSelectEditText.getText().toString().replace("<", "");
|
String text = userSelectEditText.getText().toString().replace("<", "");
|
||||||
if (text.length() != 0) {
|
if (text.length() != 0) {
|
||||||
searchDialogs(text);
|
|
||||||
searching = true;
|
searching = true;
|
||||||
searchWas = true;
|
searchWas = true;
|
||||||
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
if (listView != null) {
|
||||||
listViewAdapter.notifyDataSetChanged();
|
listView.setAdapter(searchListViewAdapter);
|
||||||
|
searchListViewAdapter.notifyDataSetChanged();
|
||||||
|
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
|
listView.setFastScrollAlwaysVisible(false);
|
||||||
|
}
|
||||||
|
listView.setFastScrollEnabled(false);
|
||||||
|
listView.setVerticalScrollBarEnabled(true);
|
||||||
|
}
|
||||||
|
if (emptyTextView != null) {
|
||||||
|
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||||
|
}
|
||||||
|
searchListViewAdapter.searchDialogs(text);
|
||||||
} else {
|
} else {
|
||||||
searchResult = null;
|
searchListViewAdapter.searchDialogs(null);
|
||||||
searchResultNames = null;
|
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
ViewGroup group = (ViewGroup) listView.getParent();
|
||||||
|
listView.setAdapter(listViewAdapter);
|
||||||
listViewAdapter.notifyDataSetChanged();
|
listViewAdapter.notifyDataSetChanged();
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
|
listView.setFastScrollAlwaysVisible(true);
|
||||||
|
}
|
||||||
|
listView.setFastScrollEnabled(true);
|
||||||
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
emptyTextView = new TextView(getParentActivity());
|
||||||
|
emptyTextView.setTextColor(0xff808080);
|
||||||
|
emptyTextView.setTextSize(24);
|
||||||
|
emptyTextView.setGravity(Gravity.CENTER);
|
||||||
|
emptyTextView.setVisibility(View.INVISIBLE);
|
||||||
|
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||||
|
linearLayout.addView(emptyTextView);
|
||||||
|
layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP;
|
||||||
|
emptyTextView.setLayoutParams(layoutParams);
|
||||||
|
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
listView = new SectionsListView(getParentActivity());
|
listView = new SectionsListView(getParentActivity());
|
||||||
listView.setEmptyView(emptyTextView);
|
listView.setEmptyView(emptyTextView);
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
@ -331,7 +316,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
listView.setFastScrollAlwaysVisible(true);
|
listView.setFastScrollAlwaysVisible(true);
|
||||||
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
||||||
}
|
}
|
||||||
((FrameLayout) fragmentView).addView(listView);
|
linearLayout.addView(listView);
|
||||||
layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
|
layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
|
||||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
@ -339,7 +324,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
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) {
|
||||||
TLRPC.User user;
|
/*TLRPC.User user;
|
||||||
int section = listViewAdapter.getSectionForPosition(i);
|
int section = listViewAdapter.getSectionForPosition(i);
|
||||||
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
||||||
if (searching && searchWas) {
|
if (searching && searchWas) {
|
||||||
|
@ -387,7 +372,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||||
listViewAdapter.notifyDataSetChanged();
|
listViewAdapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -18,7 +17,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
@ -30,22 +29,20 @@ 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.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Cells.UserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
import org.telegram.ui.Views.AvatarUpdater;
|
import org.telegram.ui.Views.AvatarUpdater;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
|
||||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
|
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
|
||||||
private PinnedHeaderListView listView;
|
private ListView listView;
|
||||||
private EditText nameTextView;
|
private EditText nameTextView;
|
||||||
private TLRPC.FileLocation avatar;
|
private TLRPC.FileLocation avatar;
|
||||||
private TLRPC.InputFile uploadedAvatar;
|
private TLRPC.InputFile uploadedAvatar;
|
||||||
|
@ -185,11 +182,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false);
|
||||||
|
|
||||||
final ImageButton button2 = (ImageButton)fragmentView.findViewById(R.id.settings_change_avatar_button);
|
if (!isBroadcast) {
|
||||||
if (isBroadcast) {
|
/*button2.setOnClickListener(new View.OnClickListener() {
|
||||||
button2.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
button2.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (getParentActivity() == null) {
|
if (getParentActivity() == null) {
|
||||||
|
@ -221,7 +215,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||||
});
|
});
|
||||||
showAlertDialog(builder);
|
showAlertDialog(builder);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
|
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
|
||||||
|
@ -238,7 +232,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||||
nameTextView.setText(nameToSet);
|
nameTextView.setText(nameToSet);
|
||||||
nameToSet = null;
|
nameToSet = null;
|
||||||
}
|
}
|
||||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setAdapter(new ListAdapter(getParentActivity()));
|
listView.setAdapter(new ListAdapter(getParentActivity()));
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
|
@ -346,18 +340,13 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ListAdapter extends SectionedBaseAdapter {
|
private class ListAdapter extends BaseFragmentAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public ListAdapter(Context context) {
|
public ListAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getItem(int section, int position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areAllItemsEnabled() {
|
public boolean areAllItemsEnabled() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -369,61 +358,22 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int section, int position) {
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
return 0;
|
TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(i));
|
||||||
}
|
if (view == null) {
|
||||||
|
view = new UserCell(mContext, 1);
|
||||||
@Override
|
|
||||||
public int getSectionCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCountForSection(int section) {
|
|
||||||
if (selectedContacts == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return selectedContacts.size();
|
((UserCell) view).setData(user, null, null, 0);
|
||||||
}
|
return view;
|
||||||
|
|
||||||
@Override
|
/*
|
||||||
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
|
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(position));
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = new UserCell(mContext, 1);
|
|
||||||
}
|
|
||||||
((UserCell) convertView).setData(user, null, null, 0);
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int section, int position) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionHeaderViewType(int section) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSectionHeaderViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = new SettingsSectionLayout(mContext);
|
convertView = new SettingsSectionLayout(mContext);
|
||||||
convertView.setBackgroundColor(0xffffffff);
|
convertView.setBackgroundColor(0xffffffff);
|
||||||
}
|
}
|
||||||
((SettingsSectionLayout) convertView).setText(LocaleController.formatPluralString("Members", selectedContacts.size()).toUpperCase());
|
((SettingsSectionLayout) convertView).setText(LocaleController.formatPluralString("Members", selectedContacts.size()).toUpperCase());
|
||||||
return convertView;
|
return convertView;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.IdenticonDrawable;
|
import org.telegram.ui.Views.IdenticonDrawable;
|
||||||
|
|
||||||
public class IdenticonActivity extends BaseFragment {
|
public class IdenticonActivity extends BaseFragment {
|
||||||
|
|
|
@ -11,6 +11,7 @@ package org.telegram.ui;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -18,6 +19,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -27,10 +29,11 @@ import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.Cells.TextSettingsCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
@ -50,6 +53,9 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
@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;
|
||||||
|
|
||||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
actionBar.setTitle(LocaleController.getString("Language", R.string.Language));
|
actionBar.setTitle(LocaleController.getString("Language", R.string.Language));
|
||||||
|
@ -90,32 +96,46 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
if (listView != null) {
|
if (listView != null) {
|
||||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||||
listView.setAdapter(searchListViewAdapter);
|
listView.setAdapter(searchListViewAdapter);
|
||||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
|
||||||
listView.setFastScrollAlwaysVisible(false);
|
|
||||||
}
|
|
||||||
listView.setFastScrollEnabled(false);
|
|
||||||
listView.setVerticalScrollBarEnabled(true);
|
|
||||||
}
|
|
||||||
if (emptyTextView != null) {
|
|
||||||
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.language_select_layout, container, false);
|
|
||||||
listAdapter = new ListAdapter(getParentActivity());
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
||||||
listView.setAdapter(listAdapter);
|
|
||||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
fragmentView = new FrameLayout(getParentActivity());
|
||||||
listView.setEmptyView(emptyTextView);
|
|
||||||
|
emptyTextView = new TextView(getParentActivity());
|
||||||
|
emptyTextView.setTextColor(0xff808080);
|
||||||
|
emptyTextView.setTextSize(24);
|
||||||
|
emptyTextView.setGravity(Gravity.CENTER);
|
||||||
|
emptyTextView.setVisibility(View.INVISIBLE);
|
||||||
|
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||||
|
((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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
|
||||||
|
listView = new ListView(getParentActivity());
|
||||||
|
listView.setEmptyView(emptyTextView);
|
||||||
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
listView.setDivider(null);
|
||||||
|
listView.setDividerHeight(0);
|
||||||
|
listView.setAdapter(listAdapter);
|
||||||
|
((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
|
||||||
|
@ -192,9 +212,6 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
@ -316,19 +333,11 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
view = new TextSettingsCell(mContext);
|
||||||
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);
|
|
||||||
|
|
||||||
LocaleController.LocaleInfo c = searchResult.get(i);
|
LocaleController.LocaleInfo c = searchResult.get(i);
|
||||||
textView.setText(c.name);
|
((TextSettingsCell) view).setText(c.name, i != searchResult.size() - 1);
|
||||||
if (i == searchResult.size() - 1) {
|
|
||||||
divider.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -392,19 +401,11 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
view = new TextSettingsCell(mContext);
|
||||||
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);
|
|
||||||
|
|
||||||
LocaleController.LocaleInfo localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
|
LocaleController.LocaleInfo localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
|
||||||
textView.setText(localeInfo.name);
|
((TextSettingsCell) view).setText(localeInfo.name, i != LocaleController.getInstance().sortedLanguages.size() - 1);
|
||||||
if (i == LocaleController.getInstance().sortedLanguages.size() - 1) {
|
|
||||||
divider.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,9 @@ 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.Adapters.DrawerLayoutAdapter;
|
import org.telegram.ui.Adapters.DrawerLayoutAdapter;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
|
import org.telegram.ui.ActionBar.ActionBarLayout;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.ActionBar.DrawerLayoutContainer;
|
import org.telegram.ui.ActionBar.DrawerLayoutContainer;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -361,7 +361,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fragmentName.equals("wallpapers")) {
|
} else if (fragmentName.equals("wallpapers")) {
|
||||||
SettingsWallpapersActivity settings = new SettingsWallpapersActivity();
|
WallpapersActivity settings = new WallpapersActivity();
|
||||||
actionBarLayout.addFragmentToStack(settings);
|
actionBarLayout.addFragmentToStack(settings);
|
||||||
settings.restoreSelfArgs(savedInstanceState);
|
settings.restoreSelfArgs(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
} else if (lastFragment instanceof GroupCreateFinalActivity && args != null) {
|
} else if (lastFragment instanceof GroupCreateFinalActivity && args != null) {
|
||||||
outState.putBundle("args", args);
|
outState.putBundle("args", args);
|
||||||
outState.putString("fragment", "group");
|
outState.putString("fragment", "group");
|
||||||
} else if (lastFragment instanceof SettingsWallpapersActivity) {
|
} else if (lastFragment instanceof WallpapersActivity) {
|
||||||
outState.putString("fragment", "wallpapers");
|
outState.putString("fragment", "wallpapers");
|
||||||
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
|
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
|
||||||
outState.putBundle("args", args);
|
outState.putBundle("args", args);
|
||||||
|
|
|
@ -35,12 +35,12 @@ import org.telegram.android.MessageObject;
|
||||||
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.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.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.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SlideView;
|
import org.telegram.ui.Views.SlideView;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -42,10 +42,284 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
|
||||||
|
|
||||||
private final static int done_button = 1;
|
private final static int done_button = 1;
|
||||||
|
|
||||||
@Override
|
/*
|
||||||
public boolean onFragmentCreate() {
|
<ScrollView
|
||||||
return super.onFragmentCreate();
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
}
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#fafafa"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<org.telegram.ui.Views.FrameLayoutFixed
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top|left">
|
||||||
|
|
||||||
|
<org.telegram.ui.LoginActivityPhoneView
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_gravity="top|left"
|
||||||
|
android:id="@+id/login_page1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:id="@+id/login_coutry_textview"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:gravity="left|center_horizontal"
|
||||||
|
android:textIsSelectable="false"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:background="@drawable/spinner_states"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:background="#808080"
|
||||||
|
android:layout_marginTop="-6.5dp"
|
||||||
|
android:layout_marginLeft="24dp"
|
||||||
|
android:layout_marginRight="24dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_gravity="top|left"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="+"
|
||||||
|
android:textColor="#a6a6a6"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_gravity="top|left"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_county_code_field"
|
||||||
|
android:width="70dp"
|
||||||
|
android:editable="true"
|
||||||
|
android:inputType="phone"
|
||||||
|
android:maxLength="4"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="18dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:imeOptions="actionNext|flagNoExtractUi"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:layout_gravity="top|left"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_phone_field"
|
||||||
|
android:inputType="phone"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="18dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:imeOptions="actionNext|flagNoExtractUi"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textColorHint="#979797"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_gravity="top|left"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_confirm_text"
|
||||||
|
android:layout_marginTop="28dp"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:lineSpacingExtra="2dp"/>
|
||||||
|
|
||||||
|
</org.telegram.ui.LoginActivityPhoneView>
|
||||||
|
|
||||||
|
<org.telegram.ui.LoginActivitySmsView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/login_page2"
|
||||||
|
android:layout_gravity="top|left"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_sms_confirm_text"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:lineSpacingExtra="2dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:width="220dp"
|
||||||
|
android:id="@+id/login_sms_code_field"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:editable="true"
|
||||||
|
android:textSize="18dp"
|
||||||
|
android:imeOptions="actionNext|flagNoExtractUi"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textColorHint="#979797"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_time_text"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:lineSpacingExtra="2dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_problem"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textColor="#316f9f"
|
||||||
|
android:lineSpacingExtra="2dp"
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:paddingBottom="12dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_below="@+id/spinner"
|
||||||
|
android:gravity="center_horizontal|bottom"
|
||||||
|
android:layout_gravity="top|left">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/wrong_number"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textColor="#316f9f"
|
||||||
|
android:lineSpacingExtra="2dp"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:paddingTop="24dp"
|
||||||
|
android:layout_marginBottom="10dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</org.telegram.ui.LoginActivitySmsView>
|
||||||
|
|
||||||
|
<org.telegram.ui.LoginActivityRegisterView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/login_page3"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_gravity="top|left">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_register_info"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:textSize="16dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_first_name_field"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="18dp"
|
||||||
|
android:imeOptions="actionNext|flagNoExtractUi"
|
||||||
|
android:layout_marginLeft="40dp"
|
||||||
|
android:layout_marginRight="40dp"
|
||||||
|
android:layout_marginTop="34dp"
|
||||||
|
android:lines="1"
|
||||||
|
android:capitalize="words"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textColorHint="#979797"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/login_last_name_field"
|
||||||
|
android:textSize="18dp"
|
||||||
|
android:imeOptions="actionNext|flagNoExtractUi"
|
||||||
|
android:layout_marginLeft="40dp"
|
||||||
|
android:layout_marginRight="40dp"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:capitalize="words"
|
||||||
|
android:autoText="false"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:textColorHint="#979797"
|
||||||
|
android:layout_marginTop="10dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_below="@+id/spinner"
|
||||||
|
android:gravity="center_horizontal|bottom"
|
||||||
|
android:minHeight="140dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:id="@+id/changed_mind"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textColor="#316f9f"
|
||||||
|
android:lineSpacingExtra="2dp"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:layout_marginTop="-40dp"
|
||||||
|
android:layout_marginBottom="20dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</org.telegram.ui.LoginActivityRegisterView>
|
||||||
|
|
||||||
|
</org.telegram.ui.Views.FrameLayoutFixed>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public void onFragmentDestroy() {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.telegram.messenger.ConnectionsManager;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SlideView;
|
import org.telegram.ui.Views.SlideView;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
|
|
@ -33,9 +33,9 @@ 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.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -40,24 +40,24 @@ import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Adapters.MessagesActivityAdapter;
|
import org.telegram.ui.Adapters.DialogsAdapter;
|
||||||
import org.telegram.ui.Adapters.MessagesActivitySearchAdapter;
|
import org.telegram.ui.Adapters.DialogsSearchAdapter;
|
||||||
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.UserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Cells.DialogCell;
|
import org.telegram.ui.Cells.DialogCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.ActionBar.MenuDrawable;
|
import org.telegram.ui.ActionBar.MenuDrawable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MessagesActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class MessagesActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
private ListView messagesListView;
|
private ListView messagesListView;
|
||||||
private MessagesActivityAdapter messagesActivityAdapter;
|
private DialogsAdapter dialogsAdapter;
|
||||||
private MessagesActivitySearchAdapter messagesActivitySearchAdapter;
|
private DialogsSearchAdapter dialogsSearchAdapter;
|
||||||
private TextView searchEmptyView;
|
private TextView searchEmptyView;
|
||||||
private View progressView;
|
private View progressView;
|
||||||
private View emptyView;
|
private View emptyView;
|
||||||
|
@ -158,13 +158,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
ViewProxy.setTranslationY(floatingButton, AndroidUtilities.dp(100));
|
ViewProxy.setTranslationY(floatingButton, AndroidUtilities.dp(100));
|
||||||
hideFloatingButton(false);
|
hideFloatingButton(false);
|
||||||
}
|
}
|
||||||
if (messagesListView.getAdapter() != messagesActivityAdapter) {
|
if (messagesListView.getAdapter() != dialogsAdapter) {
|
||||||
messagesListView.setAdapter(messagesActivityAdapter);
|
messagesListView.setAdapter(dialogsAdapter);
|
||||||
messagesActivityAdapter.notifyDataSetChanged();
|
dialogsAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (messagesActivitySearchAdapter != null) {
|
if (dialogsSearchAdapter != null) {
|
||||||
messagesActivitySearchAdapter.searchDialogs(null, false);
|
dialogsSearchAdapter.searchDialogs(null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +173,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
String text = editText.getText().toString();
|
String text = editText.getText().toString();
|
||||||
if (text.length() != 0) {
|
if (text.length() != 0) {
|
||||||
searchWas = true;
|
searchWas = true;
|
||||||
if (messagesActivitySearchAdapter != null) {
|
if (dialogsSearchAdapter != null) {
|
||||||
messagesListView.setAdapter(messagesActivitySearchAdapter);
|
messagesListView.setAdapter(dialogsSearchAdapter);
|
||||||
messagesActivitySearchAdapter.notifyDataSetChanged();
|
dialogsSearchAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
if (searchEmptyView != null && messagesListView.getEmptyView() == emptyView) {
|
if (searchEmptyView != null && messagesListView.getEmptyView() == emptyView) {
|
||||||
messagesListView.setEmptyView(searchEmptyView);
|
messagesListView.setEmptyView(searchEmptyView);
|
||||||
|
@ -183,8 +183,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
progressView.setVisibility(View.GONE);
|
progressView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (messagesActivitySearchAdapter != null) {
|
if (dialogsSearchAdapter != null) {
|
||||||
messagesActivitySearchAdapter.searchDialogs(text, serverOnly);
|
dialogsSearchAdapter.searchDialogs(text, serverOnly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -215,9 +215,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
|
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
|
||||||
|
|
||||||
messagesActivityAdapter = new MessagesActivityAdapter(getParentActivity(), serverOnly);
|
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
|
||||||
messagesActivitySearchAdapter = new MessagesActivitySearchAdapter(getParentActivity());
|
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity());
|
||||||
messagesActivitySearchAdapter.setDelegate(new MessagesActivitySearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void searchStateChanged(boolean search) {
|
public void searchStateChanged(boolean search) {
|
||||||
if (searching && searchWas && messagesListView != null) {
|
if (searching && searchWas && messagesListView != null) {
|
||||||
|
@ -229,13 +229,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
});
|
});
|
||||||
|
|
||||||
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
||||||
messagesListView.setAdapter(messagesActivityAdapter);
|
messagesListView.setAdapter(dialogsAdapter);
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
messagesListView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
messagesListView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
progressView = fragmentView.findViewById(R.id.progressLayout);
|
progressView = fragmentView.findViewById(R.id.progressLayout);
|
||||||
messagesActivityAdapter.notifyDataSetChanged();
|
dialogsAdapter.notifyDataSetChanged();
|
||||||
searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
|
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -295,17 +295,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
long dialog_id = 0;
|
long dialog_id = 0;
|
||||||
int message_id = 0;
|
int message_id = 0;
|
||||||
BaseFragmentAdapter adapter = (BaseFragmentAdapter)messagesListView.getAdapter();
|
BaseFragmentAdapter adapter = (BaseFragmentAdapter)messagesListView.getAdapter();
|
||||||
if (adapter == messagesActivityAdapter) {
|
if (adapter == dialogsAdapter) {
|
||||||
TLRPC.TL_dialog dialog = messagesActivityAdapter.getItem(i);
|
TLRPC.TL_dialog dialog = dialogsAdapter.getItem(i);
|
||||||
if (dialog == null) {
|
if (dialog == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dialog_id = dialog.id;
|
dialog_id = dialog.id;
|
||||||
} else if (adapter == messagesActivitySearchAdapter) {
|
} else if (adapter == dialogsSearchAdapter) {
|
||||||
Object obj = messagesActivitySearchAdapter.getItem(i);
|
Object obj = dialogsSearchAdapter.getItem(i);
|
||||||
if (obj instanceof TLRPC.User) {
|
if (obj instanceof TLRPC.User) {
|
||||||
dialog_id = ((TLRPC.User) obj).id;
|
dialog_id = ((TLRPC.User) obj).id;
|
||||||
if (messagesActivitySearchAdapter.isGlobalSearch(i)) {
|
if (dialogsSearchAdapter.isGlobalSearch(i)) {
|
||||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||||
users.add((TLRPC.User)obj);
|
users.add((TLRPC.User)obj);
|
||||||
MessagesController.getInstance().putUsers(users, false);
|
MessagesController.getInstance().putUsers(users, false);
|
||||||
|
@ -356,7 +356,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
if (openedDialogId == dialog_id) {
|
if (openedDialogId == dialog_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
messagesActivityAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
||||||
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
||||||
}
|
}
|
||||||
presentFragment(new ChatActivity(args));
|
presentFragment(new ChatActivity(args));
|
||||||
|
@ -501,11 +501,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (messagesActivityAdapter != null) {
|
if (dialogsAdapter != null) {
|
||||||
messagesActivityAdapter.notifyDataSetChanged();
|
dialogsAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
if (messagesActivitySearchAdapter != null) {
|
if (dialogsSearchAdapter != null) {
|
||||||
messagesActivitySearchAdapter.notifyDataSetChanged();
|
dialogsSearchAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,8 +533,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void didReceivedNotification(int id, Object... args) {
|
public void didReceivedNotification(int id, Object... args) {
|
||||||
if (id == NotificationCenter.dialogsNeedReload) {
|
if (id == NotificationCenter.dialogsNeedReload) {
|
||||||
if (messagesActivityAdapter != null) {
|
if (dialogsAdapter != null) {
|
||||||
messagesActivityAdapter.notifyDataSetChanged();
|
dialogsAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
if (messagesListView != null) {
|
if (messagesListView != null) {
|
||||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||||
|
@ -577,7 +577,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
} else {
|
} else {
|
||||||
openedDialogId = dialog_id;
|
openedDialogId = dialog_id;
|
||||||
}
|
}
|
||||||
messagesActivityAdapter.setOpenedDialogId(openedDialogId);
|
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
||||||
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,12 @@ import org.telegram.ui.Cells.ShadowSectionCell;
|
||||||
import org.telegram.ui.Cells.TextCheckCell;
|
import org.telegram.ui.Cells.TextCheckCell;
|
||||||
import org.telegram.ui.Cells.TextColorCell;
|
import org.telegram.ui.Cells.TextColorCell;
|
||||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
import org.telegram.ui.Views.ColorPickerView;
|
import org.telegram.ui.Views.ColorPickerView;
|
||||||
|
|
||||||
public class SettingsNotificationsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private boolean reseting = false;
|
private boolean reseting = false;
|
||||||
|
|
|
@ -20,16 +20,16 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.ImageLoader;
|
import org.telegram.android.ImageLoader;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
@ -282,6 +282,8 @@ public class PhotoCropActivity extends BaseFragment {
|
||||||
private boolean sameBitmap = false;
|
private boolean sameBitmap = false;
|
||||||
private boolean doneButtonPressed = false;
|
private boolean doneButtonPressed = false;
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
public PhotoCropActivity(Bundle args) {
|
public PhotoCropActivity(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
|
@ -328,33 +330,30 @@ public class PhotoCropActivity extends BaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
actionBar.setTitle(LocaleController.getString("AddContact", R.string.AddContact));
|
||||||
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onItemClick(int id) {
|
||||||
finishFragment();
|
if (id == -1) {
|
||||||
}
|
finishFragment();
|
||||||
});
|
} else if (id == done_button) {
|
||||||
View doneButton = actionBar.findViewById(R.id.done_button);
|
if (delegate != null && !doneButtonPressed) {
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
Bitmap bitmap = view.getBitmap();
|
||||||
@Override
|
if (bitmap == imageToCrop) {
|
||||||
public void onClick(View v) {
|
sameBitmap = true;
|
||||||
if (delegate != null && !doneButtonPressed) {
|
}
|
||||||
Bitmap bitmap = view.getBitmap();
|
delegate.didFinishCrop(bitmap);
|
||||||
if (bitmap == imageToCrop) {
|
doneButtonPressed = true;
|
||||||
sameBitmap = true;
|
|
||||||
}
|
}
|
||||||
delegate.didFinishCrop(bitmap);
|
finishFragment();
|
||||||
doneButtonPressed = true;
|
|
||||||
}
|
}
|
||||||
finishFragment();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
menu.addItem(done_button, R.drawable.ic_done);
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
|
||||||
|
|
||||||
fragmentView = view = new PhotoCropView(getParentActivity());
|
fragmentView = view = new PhotoCropView(getParentActivity());
|
||||||
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
|
|
@ -32,9 +32,9 @@ import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
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.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -63,9 +63,9 @@ import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||||
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
|
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
|
||||||
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.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.ClippingImageView;
|
import org.telegram.ui.Views.ClippingImageView;
|
||||||
import org.telegram.android.ImageReceiver;
|
import org.telegram.android.ImageReceiver;
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.android.MessageObject;
|
import org.telegram.android.MessageObject;
|
||||||
import org.telegram.android.PhotoObject;
|
import org.telegram.android.PhotoObject;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
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.ChatActivityEnterView;
|
import org.telegram.ui.Views.ChatActivityEnterView;
|
||||||
|
|
|
@ -54,13 +54,13 @@ import org.telegram.ui.Cells.ShadowSectionCell;
|
||||||
import org.telegram.ui.Cells.TextCell;
|
import org.telegram.ui.Cells.TextCell;
|
||||||
import org.telegram.ui.Cells.TextDetailCell;
|
import org.telegram.ui.Cells.TextDetailCell;
|
||||||
import org.telegram.ui.Cells.UserCell;
|
import org.telegram.ui.Cells.UserCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
import org.telegram.ui.Views.AvatarUpdater;
|
import org.telegram.ui.Views.AvatarUpdater;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.IdenticonDrawable;
|
import org.telegram.ui.Views.IdenticonDrawable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -325,7 +325,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||||
} else if (id == edit_name) {
|
} else if (id == edit_name) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("chat_id", chat_id);
|
args.putInt("chat_id", chat_id);
|
||||||
presentFragment(new ChatProfileChangeNameActivity(args));
|
presentFragment(new ChangeChatNameActivity(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,8 +40,8 @@ import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
import org.telegram.ui.Cells.TextColorCell;
|
import org.telegram.ui.Cells.TextColorCell;
|
||||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
import org.telegram.ui.Views.ColorPickerView;
|
import org.telegram.ui.Views.ColorPickerView;
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,13 @@ import org.telegram.ui.Cells.ShadowSectionCell;
|
||||||
import org.telegram.ui.Cells.TextCheckCell;
|
import org.telegram.ui.Cells.TextCheckCell;
|
||||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||||
import org.telegram.ui.Cells.TextSettingsCell;
|
import org.telegram.ui.Cells.TextSettingsCell;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.AvatarDrawable;
|
import org.telegram.ui.Views.AvatarDrawable;
|
||||||
import org.telegram.ui.Views.AvatarUpdater;
|
import org.telegram.ui.Views.AvatarUpdater;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.NumberPicker;
|
import org.telegram.ui.Views.NumberPicker;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -274,7 +274,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
finishFragment();
|
finishFragment();
|
||||||
} else if (id == edit_name) {
|
} else if (id == edit_name) {
|
||||||
presentFragment(new SettingsChangeNameActivity());
|
presentFragment(new ChangeNameActivity());
|
||||||
} else if (id == logout) {
|
} else if (id == logout) {
|
||||||
if (getParentActivity() == null) {
|
if (getParentActivity() == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -424,11 +424,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
}
|
}
|
||||||
} else if (i == notificationRow) {
|
} else if (i == notificationRow) {
|
||||||
presentFragment(new SettingsNotificationsActivity());
|
presentFragment(new NotificationsSettingsActivity());
|
||||||
} else if (i == blockedRow) {
|
} else if (i == blockedRow) {
|
||||||
presentFragment(new SettingsBlockedUsersActivity());
|
presentFragment(new BlockedUsersActivity());
|
||||||
} else if (i == backgroundRow) {
|
} else if (i == backgroundRow) {
|
||||||
presentFragment(new SettingsWallpapersActivity());
|
presentFragment(new WallpapersActivity());
|
||||||
} else if (i == askQuestionRow) {
|
} else if (i == askQuestionRow) {
|
||||||
if (getParentActivity() == null) {
|
if (getParentActivity() == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -627,7 +627,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||||
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
||||||
showAlertDialog(builder);
|
showAlertDialog(builder);
|
||||||
} else if (i == usernameRow) {
|
} else if (i == usernameRow) {
|
||||||
presentFragment(new SettingsChangeUsernameActivity());
|
presentFragment(new ChangeUsernameActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,9 +46,9 @@ import org.telegram.android.MediaController;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.VideoSeekBarView;
|
import org.telegram.ui.Views.VideoSeekBarView;
|
||||||
import org.telegram.ui.Views.VideoTimelineView;
|
import org.telegram.ui.Views.VideoTimelineView;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.LaunchActivity;
|
import org.telegram.ui.LaunchActivity;
|
||||||
import org.telegram.ui.PhotoCropActivity;
|
import org.telegram.ui.PhotoCropActivity;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
|
|
@ -1,270 +0,0 @@
|
||||||
/*
|
|
||||||
* This is the source code of Telegram for Android v. 1.3.2.
|
|
||||||
* 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.Views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.*;
|
|
||||||
import android.widget.AbsListView.OnScrollListener;
|
|
||||||
|
|
||||||
import org.telegram.messenger.FileLog;
|
|
||||||
|
|
||||||
public class PinnedHeaderListView extends ListView implements OnScrollListener, View.OnTouchListener {
|
|
||||||
|
|
||||||
private OnScrollListener mOnScrollListener;
|
|
||||||
|
|
||||||
public static interface PinnedSectionedHeaderAdapter {
|
|
||||||
public boolean isSectionHeader(int position);
|
|
||||||
|
|
||||||
public int getSectionForPosition(int position);
|
|
||||||
|
|
||||||
public View getSectionHeaderView(int section, View convertView, ViewGroup parent);
|
|
||||||
|
|
||||||
public int getSectionHeaderViewType(int section);
|
|
||||||
|
|
||||||
public int getCount();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private PinnedSectionedHeaderAdapter mAdapter;
|
|
||||||
private OnTouchListener mForwardingTouchListener = null;
|
|
||||||
private float mLastUpEventY = -1;
|
|
||||||
private View mCurrentHeader;
|
|
||||||
private int mCurrentHeaderViewType = 0;
|
|
||||||
private float mHeaderOffset;
|
|
||||||
private boolean mShouldPin = true;
|
|
||||||
private int mCurrentSection = 0;
|
|
||||||
private int mWidthMode;
|
|
||||||
public int exHeaderRightPadding = 0;
|
|
||||||
|
|
||||||
public PinnedHeaderListView(Context context) {
|
|
||||||
super(context);
|
|
||||||
super.setOnScrollListener(this);
|
|
||||||
super.setOnTouchListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PinnedHeaderListView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
super.setOnScrollListener(this);
|
|
||||||
super.setOnTouchListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PinnedHeaderListView(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
super.setOnScrollListener(this);
|
|
||||||
super.setOnTouchListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPinHeaders(boolean shouldPin) {
|
|
||||||
mShouldPin = shouldPin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAdapter(ListAdapter adapter) {
|
|
||||||
if (mAdapter == adapter) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mCurrentHeader = null;
|
|
||||||
if (adapter instanceof PinnedSectionedHeaderAdapter) {
|
|
||||||
mAdapter = (PinnedSectionedHeaderAdapter) 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mAdapter.getCount() == 0 || !mShouldPin || (firstVisibleItem < getHeaderViewsCount())) {
|
|
||||||
mCurrentHeader = null;
|
|
||||||
mHeaderOffset = 0.0f;
|
|
||||||
for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {
|
|
||||||
View header = getChildAt(i);
|
|
||||||
if (header != null) {
|
|
||||||
header.setVisibility(VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
firstVisibleItem -= getHeaderViewsCount();
|
|
||||||
|
|
||||||
int section = mAdapter.getSectionForPosition(firstVisibleItem);
|
|
||||||
int viewType = mAdapter.getSectionHeaderViewType(section);
|
|
||||||
mCurrentHeader = getSectionHeaderView(section, mCurrentHeaderViewType != viewType ? null : mCurrentHeader);
|
|
||||||
if (mCurrentHeader != null && mCurrentHeader.getPaddingLeft() != getPaddingLeft()) {
|
|
||||||
mCurrentHeader.setPadding(getPaddingLeft(), mCurrentHeader.getPaddingTop(), getPaddingRight() + (int)(getResources().getDisplayMetrics().density * exHeaderRightPadding), 0);
|
|
||||||
}
|
|
||||||
ensurePinnedHeaderLayout(mCurrentHeader, false);
|
|
||||||
mCurrentHeaderViewType = viewType;
|
|
||||||
|
|
||||||
mHeaderOffset = 0.0f;
|
|
||||||
|
|
||||||
for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {
|
|
||||||
if (mAdapter.isSectionHeader(i)) {
|
|
||||||
View header = getChildAt(i - firstVisibleItem);
|
|
||||||
float headerTop = header.getTop();
|
|
||||||
float pinnedHeaderHeight = mCurrentHeader.getMeasuredHeight();
|
|
||||||
header.setVisibility(VISIBLE);
|
|
||||||
if (pinnedHeaderHeight >= headerTop && headerTop > -1) {
|
|
||||||
mHeaderOffset = headerTop - header.getHeight();
|
|
||||||
} else if (headerTop <= 0) {
|
|
||||||
header.setVisibility(INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = section != mCurrentSection || oldView == null;
|
|
||||||
|
|
||||||
View view = mAdapter.getSectionHeaderView(section, oldView, this);
|
|
||||||
if (shouldLayout) {
|
|
||||||
// a new section, thus a new header. We should lay it out again
|
|
||||||
ensurePinnedHeaderLayout(view, false);
|
|
||||||
mCurrentSection = section;
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
||||||
super.onSizeChanged(w, h, oldw, oldh);
|
|
||||||
if (mAdapter == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mCurrentHeader != null) {
|
|
||||||
ensurePinnedHeaderLayout(mCurrentHeader, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
|
|
||||||
if (header.isLayoutRequested() || forceLayout) {
|
|
||||||
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), mWidthMode);
|
|
||||||
|
|
||||||
int heightSpec;
|
|
||||||
ViewGroup.LayoutParams layoutParams = header.getLayoutParams();
|
|
||||||
if (layoutParams != null && layoutParams.height > 0) {
|
|
||||||
heightSpec = MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY);
|
|
||||||
} else {
|
|
||||||
heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
|
||||||
}
|
|
||||||
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 || !mShouldPin || mCurrentHeader == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int saveCount = canvas.save();
|
|
||||||
canvas.translate(0, mHeaderOffset);
|
|
||||||
canvas.clipRect(0, 0, getWidth(), mCurrentHeader.getMeasuredHeight()); // needed for < HONEYCOMB
|
|
||||||
mCurrentHeader.draw(canvas);
|
|
||||||
canvas.restoreToCount(saveCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean performItemClick(View view, int position, long id) {
|
|
||||||
if (mAdapter != null && mLastUpEventY > 0 && mCurrentHeader != null && mLastUpEventY < mCurrentHeader.getBottom()) {
|
|
||||||
mCurrentHeader.performClick();
|
|
||||||
mLastUpEventY = -1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.performItemClick(view, position, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setOnTouchListener(OnTouchListener l) {
|
|
||||||
mForwardingTouchListener = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
if (mForwardingTouchListener != null) {
|
|
||||||
mForwardingTouchListener.onTouch(v, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mCurrentHeader != null && event.getY() < mCurrentHeader.getHeight()) {
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
|
||||||
mLastUpEventY = event.getY();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setOnScrollListener(OnScrollListener l) {
|
|
||||||
mOnScrollListener = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
|
|
||||||
mWidthMode = MeasureSpec.getMode(widthMeasureSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnItemClickListener(PinnedHeaderListView.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;
|
|
||||||
if (adapterView.getAdapter() instanceof HeaderViewListAdapter) {
|
|
||||||
HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
|
|
||||||
adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
|
|
||||||
} else {
|
|
||||||
adapter = (SectionedBaseAdapter) adapterView.getAdapter();
|
|
||||||
}
|
|
||||||
int section = adapter.getSectionForPosition(rawPosition);
|
|
||||||
int position = adapter.getPositionInSectionForPosition(rawPosition);
|
|
||||||
|
|
||||||
if (position == -1) {
|
|
||||||
onSectionClick(adapterView, view, section, id);
|
|
||||||
} else {
|
|
||||||
onItemClick(adapterView, view, section, position, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void onItemClick(AdapterView<?> adapterView, View view, int section, int position, long id);
|
|
||||||
|
|
||||||
public abstract void onSectionClick(AdapterView<?> adapterView, View view, int section, long id);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,225 +0,0 @@
|
||||||
/*
|
|
||||||
* This is the source code of Telegram for Android v. 1.3.2.
|
|
||||||
* 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.Views;
|
|
||||||
|
|
||||||
import android.util.SparseArray;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
|
||||||
|
|
||||||
public abstract class SectionedBaseAdapter extends BaseFragmentAdapter implements PinnedHeaderListView.PinnedSectionedHeaderAdapter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds the calculated values of @{link getPositionInSectionForPosition}
|
|
||||||
*/
|
|
||||||
private SparseArray<Integer> mSectionPositionCache;
|
|
||||||
/**
|
|
||||||
* Holds the calculated values of @{link getSectionForPosition}
|
|
||||||
*/
|
|
||||||
private SparseArray<Integer> mSectionCache;
|
|
||||||
/**
|
|
||||||
* Holds the calculated values of @{link getCountForSection}
|
|
||||||
*/
|
|
||||||
private SparseArray<Integer> mSectionCountCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caches the item count
|
|
||||||
*/
|
|
||||||
private int mCount;
|
|
||||||
/**
|
|
||||||
* Caches the section count
|
|
||||||
*/
|
|
||||||
private int mSectionCount;
|
|
||||||
|
|
||||||
public SectionedBaseAdapter() {
|
|
||||||
super();
|
|
||||||
mSectionCache = new SparseArray<Integer>();
|
|
||||||
mSectionPositionCache = new SparseArray<Integer>();
|
|
||||||
mSectionCountCache = new SparseArray<Integer>();
|
|
||||||
mCount = -1;
|
|
||||||
mSectionCount = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyDataSetChanged() {
|
|
||||||
mSectionCache.clear();
|
|
||||||
mSectionPositionCache.clear();
|
|
||||||
mSectionCountCache.clear();
|
|
||||||
mCount = -1;
|
|
||||||
mSectionCount = -1;
|
|
||||||
super.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyDataSetInvalidated() {
|
|
||||||
mSectionCache.clear();
|
|
||||||
mSectionPositionCache.clear();
|
|
||||||
mSectionCountCache.clear();
|
|
||||||
mCount = -1;
|
|
||||||
mSectionCount = -1;
|
|
||||||
super.notifyDataSetInvalidated();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean areAllItemsEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled(int position) {
|
|
||||||
return !isSectionHeader(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final int getCount() {
|
|
||||||
if (mCount >= 0) {
|
|
||||||
return mCount;
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
for (int i = 0; i < internalGetSectionCount(); i++) {
|
|
||||||
count += internalGetCountForSection(i);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
mCount = count;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Object getItem(int position) {
|
|
||||||
return getItem(getSectionForPosition(position), getPositionInSectionForPosition(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final long getItemId(int position) {
|
|
||||||
return getItemId(getSectionForPosition(position), getPositionInSectionForPosition(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
if (isSectionHeader(position)) {
|
|
||||||
return getSectionHeaderView(getSectionForPosition(position), convertView, parent);
|
|
||||||
}
|
|
||||||
return getItemView(getSectionForPosition(position), getPositionInSectionForPosition(position), convertView, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final int getItemViewType(int position) {
|
|
||||||
if (isSectionHeader(position)) {
|
|
||||||
return getItemViewTypeCount() + getSectionHeaderViewType(getSectionForPosition(position));
|
|
||||||
}
|
|
||||||
return getItemViewType(getSectionForPosition(position), getPositionInSectionForPosition(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final int getViewTypeCount() {
|
|
||||||
return getItemViewTypeCount() + getSectionHeaderViewTypeCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getSectionForPosition(int position) {
|
|
||||||
// first try to retrieve values from cache
|
|
||||||
Integer cachedSection = mSectionCache.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 + 1;
|
|
||||||
if (position >= sectionStart && position < sectionEnd) {
|
|
||||||
mSectionCache.put(position, i);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
sectionStart = sectionEnd;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPositionInSectionForPosition(int position) {
|
|
||||||
if (position == 0) {
|
|
||||||
position = 1;
|
|
||||||
}
|
|
||||||
// first try to retrieve values from cache
|
|
||||||
Integer cachedPosition = mSectionPositionCache.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 + 1;
|
|
||||||
if (position >= sectionStart && position < sectionEnd) {
|
|
||||||
int positionInSection = position - sectionStart - 1;
|
|
||||||
mSectionPositionCache.put(position, positionInSection);
|
|
||||||
return positionInSection;
|
|
||||||
}
|
|
||||||
sectionStart = sectionEnd;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isSectionHeader(int position) {
|
|
||||||
int sectionStart = 0;
|
|
||||||
for (int i = 0; i < internalGetSectionCount(); i++) {
|
|
||||||
if (position == sectionStart) {
|
|
||||||
return true;
|
|
||||||
} else if (position < sectionStart) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sectionStart += internalGetCountForSection(i) + 1;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemViewType(int section, int position) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSectionHeaderViewType(int section) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSectionHeaderViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Object getItem(int section, int position);
|
|
||||||
|
|
||||||
public abstract long getItemId(int section, int position);
|
|
||||||
|
|
||||||
public abstract int getSectionCount();
|
|
||||||
|
|
||||||
public abstract int getCountForSection(int section);
|
|
||||||
|
|
||||||
public abstract View getItemView(int section, int position, View convertView, ViewGroup parent);
|
|
||||||
|
|
||||||
public abstract View getSectionHeaderView(int section, View convertView, ViewGroup parent);
|
|
||||||
|
|
||||||
private int internalGetCountForSection(int section) {
|
|
||||||
Integer cachedSectionCount = mSectionCountCache.get(section);
|
|
||||||
if (cachedSectionCount != null) {
|
|
||||||
return cachedSectionCount;
|
|
||||||
}
|
|
||||||
int sectionCount = getCountForSection(section);
|
|
||||||
mSectionCountCache.put(section, sectionCount);
|
|
||||||
return sectionCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int internalGetSectionCount() {
|
|
||||||
if (mSectionCount >= 0) {
|
|
||||||
return mSectionCount;
|
|
||||||
}
|
|
||||||
mSectionCount = getSectionCount();
|
|
||||||
return mSectionCount;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,7 +14,6 @@ import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
@ -200,16 +199,4 @@ public class SectionsListView extends ListView implements AbsListView.OnScrollLi
|
||||||
public void setOnItemClickListener(SectionsListView.OnItemClickListener listener) {
|
public void setOnItemClickListener(SectionsListView.OnItemClickListener listener) {
|
||||||
super.setOnItemClickListener(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,6 @@ public class Switch extends CompoundButton {
|
||||||
final float targetPosition = newCheckedState ? 1 : 0;
|
final float targetPosition = newCheckedState ? 1 : 0;
|
||||||
mPositionAnimator = ObjectAnimatorProxy.ofFloatProxy(this, "thumbPosition", targetPosition);
|
mPositionAnimator = ObjectAnimatorProxy.ofFloatProxy(this, "thumbPosition", targetPosition);
|
||||||
mPositionAnimator.setDuration(THUMB_ANIMATION_DURATION);
|
mPositionAnimator.setDuration(THUMB_ANIMATION_DURATION);
|
||||||
mPositionAnimator.setAutoCancel(true);
|
|
||||||
mPositionAnimator.start();
|
mPositionAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,8 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.ImageLoader;
|
import org.telegram.android.ImageLoader;
|
||||||
|
@ -45,8 +43,10 @@ import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||||
|
import org.telegram.ui.ActionBar.ActionBar;
|
||||||
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
import org.telegram.ui.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.HorizontalListView;
|
import org.telegram.ui.Views.HorizontalListView;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -54,7 +54,8 @@ import java.io.FileOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class SettingsWallpapersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class WallpapersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
|
||||||
private HorizontalListView listView;
|
private HorizontalListView listView;
|
||||||
private ListAdapter listAdapter;
|
private ListAdapter listAdapter;
|
||||||
private ImageView backgroundImage;
|
private ImageView backgroundImage;
|
||||||
|
@ -69,6 +70,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||||
private TLRPC.PhotoSize loadingSize = null;
|
private TLRPC.PhotoSize loadingSize = null;
|
||||||
private String currentPicturePath;
|
private String currentPicturePath;
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
|
@ -99,63 +102,60 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
actionBar.setTitle(LocaleController.getString("ChatBackground", R.string.ChatBackground));
|
||||||
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onItemClick(int id) {
|
||||||
finishFragment();
|
if (id == -1) {
|
||||||
}
|
finishFragment();
|
||||||
});
|
} else if (id == done_button) {
|
||||||
doneButton = actionBar.findViewById(R.id.done_button);
|
boolean done;
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||||
@Override
|
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||||
public void onClick(View view) {
|
int width = AndroidUtilities.displaySize.x;
|
||||||
boolean done;
|
int height = AndroidUtilities.displaySize.y;
|
||||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
if (width > height) {
|
||||||
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
|
int temp = width;
|
||||||
int width = AndroidUtilities.displaySize.x;
|
width = height;
|
||||||
int height = AndroidUtilities.displaySize.y;
|
height = temp;
|
||||||
if (width > height) {
|
}
|
||||||
int temp = width;
|
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, Math.min(width, height));
|
||||||
width = height;
|
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||||
height = temp;
|
File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
|
||||||
}
|
|
||||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, Math.min(width, height));
|
|
||||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
|
||||||
File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
|
|
||||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
|
||||||
try {
|
|
||||||
done = Utilities.copyFile(f, toFile);
|
|
||||||
} catch (Exception e) {
|
|
||||||
done = false;
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (selectedBackground == -1) {
|
|
||||||
File fromFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
|
|
||||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
||||||
done = fromFile.renameTo(toFile);
|
try {
|
||||||
|
done = Utilities.copyFile(f, toFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
done = false;
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
done = true;
|
if (selectedBackground == -1) {
|
||||||
|
File fromFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
|
||||||
|
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
||||||
|
done = fromFile.renameTo(toFile);
|
||||||
|
} else {
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
editor.putInt("selectedBackground", selectedBackground);
|
editor.putInt("selectedBackground", selectedBackground);
|
||||||
editor.putInt("selectedColor", selectedColor);
|
editor.putInt("selectedColor", selectedColor);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
ApplicationLoader.cachedWallpaper = null;
|
ApplicationLoader.cachedWallpaper = null;
|
||||||
|
}
|
||||||
|
finishFragment();
|
||||||
}
|
}
|
||||||
finishFragment();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||||
textView.setText(LocaleController.getString("Set", R.string.Set).toUpperCase());
|
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
|
||||||
listAdapter = new ListAdapter(getParentActivity());
|
listAdapter = new ListAdapter(getParentActivity());
|
Before Width: | Height: | Size: 928 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 214 B |
Before Width: | Height: | Size: 755 B |
Before Width: | Height: | Size: 1.4 KiB |
BIN
TMessagesProj/src/main/res/drawable-hdpi/ic_done.png
Normal file → Executable file
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 971 B |
Before Width: | Height: | Size: 978 B |
Before Width: | Height: | Size: 728 B |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 839 B |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 631 B |
Before Width: | Height: | Size: 638 B |
Before Width: | Height: | Size: 619 B |
Before Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 443 B |
Before Width: | Height: | Size: 1.3 KiB |
BIN
TMessagesProj/src/main/res/drawable-mdpi/ic_done.png
Normal file → Executable file
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 155 B |