More Android L design
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -47,6 +47,7 @@ public class ActionBar extends FrameLayout {
|
|||
private ActionBarMenu menu;
|
||||
private ActionBarMenu actionMode;
|
||||
private View actionOverlay;
|
||||
|
||||
protected boolean isSearchFieldVisible;
|
||||
protected int itemsBackgroundResourceId;
|
||||
private boolean isBackOverlayVisible;
|
||||
|
@ -69,23 +70,6 @@ public class ActionBar extends FrameLayout {
|
|||
titleFrameLayout.setLayoutParams(layoutParams);
|
||||
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
||||
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) {
|
||||
|
@ -139,13 +123,20 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
|
||||
int x = 0;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
x = AndroidUtilities.dp(80);
|
||||
if (backButtonImageView != null) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
x = AndroidUtilities.dp(80);
|
||||
} else {
|
||||
x = AndroidUtilities.dp(72);
|
||||
}
|
||||
} else {
|
||||
x = AndroidUtilities.dp(72);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
x = AndroidUtilities.dp(26);
|
||||
} else {
|
||||
x = AndroidUtilities.dp(18);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (menu != null) {
|
||||
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16));
|
||||
}
|
||||
|
@ -191,11 +182,39 @@ public class ActionBar extends FrameLayout {
|
|||
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) {
|
||||
if (backButtonImageView == null) {
|
||||
createBackButtonImage();
|
||||
}
|
||||
backButtonImageView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setBackButtonImage(int resource) {
|
||||
if (backButtonImageView == null) {
|
||||
createBackButtonImage();
|
||||
}
|
||||
backButtonImageView.setImageResource(resource);
|
||||
}
|
||||
|
||||
|
@ -485,7 +504,9 @@ public class ActionBar extends FrameLayout {
|
|||
|
||||
public void setItemsBackground(int resourceId) {
|
||||
itemsBackgroundResourceId = resourceId;
|
||||
backButtonImageView.setBackgroundResource(resourceId);
|
||||
if (backButtonImageView != null) {
|
||||
backButtonImageView.setBackgroundResource(resourceId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
//Thanks to https://github.com/JakeWharton/ActionBarSherlock/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
|
@ -15,12 +15,6 @@ import android.widget.BaseAdapter;
|
|||
|
||||
public class BaseFragmentAdapter extends BaseAdapter {
|
||||
|
||||
public void onFragmentCreate() {
|
||||
}
|
||||
|
||||
public void onFragmentDestroy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 0;
|
||||
|
|
|
@ -120,7 +120,7 @@ public abstract class BaseSectionsAdapter extends BaseFragmentAdapter {
|
|||
}
|
||||
sectionStart = sectionEnd;
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getPositionInSectionForPosition(int position) {
|
||||
|
@ -139,7 +139,7 @@ public abstract class BaseSectionsAdapter extends BaseFragmentAdapter {
|
|||
}
|
||||
sectionStart = sectionEnd;
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public abstract int getSectionCount();
|
||||
|
|
|
@ -28,14 +28,14 @@ import org.telegram.ui.Cells.UserCell;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ContactsActivityAdapter extends BaseSectionsAdapter {
|
||||
public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private boolean onlyUsers;
|
||||
private boolean needPhonebook;
|
||||
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;
|
||||
onlyUsers = arg1;
|
||||
needPhonebook = arg2;
|
|
@ -24,26 +24,32 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Cells.GreySectionCell;
|
||||
import org.telegram.ui.Cells.ProfileSearchCell;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
||||
public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
private Context mContext;
|
||||
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
||||
private ArrayList<TLRPC.User> searchResult = new ArrayList<TLRPC.User>();
|
||||
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
|
||||
private Timer searchTimer;
|
||||
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;
|
||||
ignoreUsers = arg1;
|
||||
allowUsernameSearch = usernameSearch;
|
||||
}
|
||||
|
||||
public void setUseUserCell(boolean value) {
|
||||
useUserCell = value;
|
||||
}
|
||||
|
||||
public void searchDialogs(final String query) {
|
||||
try {
|
||||
if (searchTimer != null) {
|
||||
|
@ -202,10 +208,13 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
} else {
|
||||
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);
|
||||
if (user != null) {
|
||||
CharSequence username = null;
|
||||
|
@ -227,13 +236,16 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
((ProfileSearchCell) view).setData(user, null, null, name, username);
|
||||
|
||||
if (ignoreUsers != null) {
|
||||
if (ignoreUsers.containsKey(user.id)) {
|
||||
((ProfileSearchCell) view).drawAlpha = 0.5f;
|
||||
} else {
|
||||
((ProfileSearchCell) view).drawAlpha = 1.0f;
|
||||
if (useUserCell) {
|
||||
((UserCell) view).setData(user, name, username, 0);
|
||||
} else {
|
||||
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
|
||||
if (ignoreUsers != null) {
|
||||
if (ignoreUsers.containsKey(user.id)) {
|
||||
((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.ui.Cells.DialogCell;
|
||||
|
||||
public class MessagesActivityAdapter extends BaseFragmentAdapter {
|
||||
public class DialogsAdapter extends BaseFragmentAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private boolean serverOnly;
|
||||
private long openedDialogId;
|
||||
|
||||
public MessagesActivityAdapter(Context context, boolean onlyFromServer) {
|
||||
public DialogsAdapter(Context context, boolean onlyFromServer) {
|
||||
mContext = context;
|
||||
serverOnly = onlyFromServer;
|
||||
}
|
|
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
||||
public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
private Context mContext;
|
||||
private Timer searchTimer;
|
||||
private ArrayList<TLObject> searchResult = new ArrayList<TLObject>();
|
||||
|
@ -53,7 +53,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
public abstract void searchStateChanged(boolean searching);
|
||||
}
|
||||
|
||||
public MessagesActivitySearchAdapter(Context context) {
|
||||
public DialogsSearchAdapter(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
|
@ -18,8 +18,6 @@ package org.telegram.ui.Animation;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
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.Cells.TextInfoCell;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
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;
|
||||
|
||||
public class SettingsBlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
|
||||
public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
|
||||
private ListView listView;
|
||||
private ListAdapter listViewAdapter;
|
||||
private FrameLayout progressView;
|
||||
|
@ -79,7 +79,7 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
|||
args.putBoolean("destroyAfterSelect", true);
|
||||
args.putBoolean("returnAsResult", true);
|
||||
ContactsActivity fragment = new ContactsActivity(args);
|
||||
fragment.setDelegate(SettingsBlockedUsersActivity.this);
|
||||
fragment.setDelegate(BlockedUsersActivity.this);
|
||||
presentFragment(fragment);
|
||||
}
|
||||
}
|
|
@ -109,7 +109,7 @@ public class DialogCell extends BaseCell {
|
|||
if (namePaint == null) {
|
||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(17));
|
||||
namePaint.setColor(0xff222222);
|
||||
namePaint.setColor(0xff212121);
|
||||
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
|
||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
|
|
|
@ -40,4 +40,8 @@ public class LetterSectionCell extends FrameLayout {
|
|||
public void setLetter(String letter) {
|
||||
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) {
|
||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(17));
|
||||
namePaint.setColor(0xff222222);
|
||||
namePaint.setColor(0xff212121);
|
||||
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
|
||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.telegram.ui.Cells;
|
|||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
|
@ -41,10 +42,11 @@ public class TextSettingsCell extends FrameLayout {
|
|||
textView.setLines(1);
|
||||
textView.setMaxLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||
addView(textView);
|
||||
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(17);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(17);
|
||||
|
@ -57,6 +59,7 @@ public class TextSettingsCell extends FrameLayout {
|
|||
valueTextView.setLines(1);
|
||||
valueTextView.setMaxLines(1);
|
||||
valueTextView.setSingleLine(true);
|
||||
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
|
||||
addView(valueTextView);
|
||||
layoutParams = (LayoutParams) valueTextView.getLayoutParams();
|
||||
|
@ -70,7 +73,17 @@ public class TextSettingsCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
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) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.content.Context;
|
|||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -33,6 +34,7 @@ public class UserCell extends FrameLayout {
|
|||
private TextView nameTextView;
|
||||
private TextView statusTextView;
|
||||
private ImageView imageView;
|
||||
private CheckBox checkBox;
|
||||
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private TLRPC.User currentUser = null;
|
||||
|
@ -65,7 +67,7 @@ public class UserCell extends FrameLayout {
|
|||
avatarDrawable = new AvatarDrawable();
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
nameTextView.setTextColor(0xff000000);
|
||||
nameTextView.setTextColor(0xff212121);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
|
||||
nameTextView.setLines(1);
|
||||
nameTextView.setMaxLines(1);
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -29,16 +28,20 @@ import org.telegram.android.LocaleController;
|
|||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
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 View headerLabelView;
|
||||
private int chat_id;
|
||||
private View doneButton;
|
||||
|
||||
public ChatProfileChangeNameActivity(Bundle args) {
|
||||
private final static int done_button = 1;
|
||||
|
||||
public ChangeChatNameActivity(Bundle args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
|
@ -52,40 +55,34 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
||||
|
||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
doneButton = actionBar.findViewById(R.id.done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (firstNameField.getText().length() != 0) {
|
||||
saveName();
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == done_button) {
|
||||
if (firstNameField.getText().length() != 0) {
|
||||
saveName();
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||
|
||||
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
|
||||
|
||||
fragmentView = new LinearLayout(inflater.getContext());
|
||||
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);
|
||||
|
||||
SettingsSectionLayout settingsSectionLayout = new SettingsSectionLayout(inflater.getContext());
|
||||
((LinearLayout) fragmentView).addView(settingsSectionLayout);
|
||||
|
||||
firstNameField = new EditText(inflater.getContext());
|
||||
firstNameField.setText(currentChat.title);
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
|
||||
|
@ -114,15 +111,15 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
|||
((LinearLayout) fragmentView).addView(firstNameField);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(15);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(16);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(16);
|
||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
firstNameField.setLayoutParams(layoutParams);
|
||||
|
||||
if (chat_id > 0) {
|
||||
settingsSectionLayout.setText(LocaleController.getString("EnterGroupNameTitle", R.string.EnterGroupNameTitle));
|
||||
firstNameField.setHint(LocaleController.getString("GroupName", R.string.GroupName));
|
||||
} else {
|
||||
settingsSectionLayout.setText(LocaleController.getString("EnterListName", R.string.EnterListName).toUpperCase());
|
||||
firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
|
||||
}
|
||||
firstNameField.setSelection(firstNameField.length());
|
|
@ -18,7 +18,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -33,40 +32,44 @@ import org.telegram.android.NotificationCenter;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
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;
|
||||
|
||||
public class SettingsChangeNameActivity extends BaseFragment {
|
||||
public class ChangeNameActivity extends BaseFragment {
|
||||
|
||||
private EditText firstNameField;
|
||||
private EditText lastNameField;
|
||||
private View headerLabelView;
|
||||
private View doneButton;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
doneButton = actionBar.findViewById(R.id.done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (firstNameField.getText().length() != 0) {
|
||||
saveName();
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == done_button) {
|
||||
if (firstNameField.getText().length() != 0) {
|
||||
saveName();
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||
|
||||
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
||||
if (user == null) {
|
|
@ -24,7 +24,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -41,12 +40,14 @@ import org.telegram.messenger.RPCRequest;
|
|||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
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 java.util.ArrayList;
|
||||
|
||||
public class SettingsChangeUsernameActivity extends BaseFragment {
|
||||
public class ChangeUsernameActivity extends BaseFragment {
|
||||
|
||||
private EditText firstNameField;
|
||||
private View doneButton;
|
||||
|
@ -56,28 +57,27 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
private Runnable checkRunnable = null;
|
||||
private boolean lastNameAvailable = false;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
doneButton = actionBar.findViewById(R.id.done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
saveName();
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == done_button) {
|
||||
saveName();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
||||
if (user == null) {
|
|
@ -71,12 +71,12 @@ import org.telegram.ui.Cells.ChatBaseCell;
|
|||
import org.telegram.ui.Cells.ChatContactCell;
|
||||
import org.telegram.ui.Cells.ChatMediaCell;
|
||||
import org.telegram.ui.Cells.ChatMessageCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
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.android.ImageReceiver;
|
||||
import org.telegram.ui.Views.LayoutListView;
|
||||
|
@ -2364,6 +2364,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
public void onClick(View v) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", currentUser.id);
|
||||
args.putBoolean("addContact", true);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
}
|
||||
});
|
||||
|
@ -3292,6 +3293,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", messageObject.messageOwner.media.user_id);
|
||||
args.putString("phone", messageObject.messageOwner.media.phone_number);
|
||||
args.putBoolean("addContact", true);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -29,13 +28,14 @@ import org.telegram.messenger.TLRPC;
|
|||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
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.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
private int user_id;
|
||||
private String phone = null;
|
||||
|
||||
private View doneButton;
|
||||
private EditText firstNameField;
|
||||
private EditText lastNameField;
|
||||
|
@ -43,6 +43,12 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||
private TextView onlineText;
|
||||
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) {
|
||||
super(args);
|
||||
}
|
||||
|
@ -52,6 +58,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||
user_id = getArguments().getInt("user_id", 0);
|
||||
phone = getArguments().getString("phone");
|
||||
addContact = getArguments().getBoolean("addContact", false);
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
return user != null && super.onFragmentCreate();
|
||||
}
|
||||
|
@ -65,32 +72,33 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
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
|
||||
public void onClick(View view) {
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
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);
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
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());
|
||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||
|
||||
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.UserConfig;
|
||||
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsSearchAdapter;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.SectionsListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -56,7 +56,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
private BaseSectionsAdapter listViewAdapter;
|
||||
private TextView emptyTextView;
|
||||
private SectionsListView listView;
|
||||
private ContactsActivitySearchAdapter searchListViewAdapter;
|
||||
private ContactsSearchAdapter searchListViewAdapter;
|
||||
|
||||
private boolean searchWas;
|
||||
private boolean searching;
|
||||
|
@ -150,7 +150,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
listView.setFastScrollEnabled(true);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
|
||||
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);
|
||||
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers);
|
||||
searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
|
||||
listViewAdapter = new ContactsAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers);
|
||||
|
||||
fragmentView = new FrameLayout(getParentActivity());
|
||||
|
||||
|
|
|
@ -8,40 +8,30 @@
|
|||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||
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;
|
||||
import org.telegram.ui.Adapters.CountryAdapter;
|
||||
import org.telegram.ui.Adapters.CountryAdapter.Country;
|
||||
import org.telegram.ui.Adapters.CountrySearchAdapter;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.SectionsListView;
|
||||
|
||||
public class CountrySelectActivity extends BaseFragment {
|
||||
|
||||
|
@ -49,68 +39,18 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
public abstract void didSelectCountry(String name);
|
||||
}
|
||||
|
||||
private SectionedBaseAdapter listViewAdapter;
|
||||
private PinnedHeaderListView listView;
|
||||
private SectionsListView listView;
|
||||
private TextView emptyTextView;
|
||||
private CountryAdapter listViewAdapter;
|
||||
private CountrySearchAdapter searchListViewAdapter;
|
||||
|
||||
private boolean searchWas;
|
||||
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 Timer searchTimer;
|
||||
public ArrayList<Country> searchResult;
|
||||
|
||||
public static class Country {
|
||||
public String name;
|
||||
public String code;
|
||||
public String shortname;
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -120,7 +60,7 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
public View createView(LayoutInflater inflater, final ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
|
@ -144,16 +84,11 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public void onSearchCollapse() {
|
||||
search(null);
|
||||
searchListViewAdapter.search(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
ViewGroup group = (ViewGroup) listView.getParent();
|
||||
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) {
|
||||
listView.setFastScrollAlwaysVisible(true);
|
||||
}
|
||||
|
@ -166,11 +101,10 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
@Override
|
||||
public void onTextChanged(EditText editText) {
|
||||
String text = editText.getText().toString();
|
||||
search(text);
|
||||
searchListViewAdapter.search(text);
|
||||
if (text.length() != 0) {
|
||||
searchWas = true;
|
||||
if (listView != null) {
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setAdapter(searchListViewAdapter);
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
listView.setFastScrollAlwaysVisible(false);
|
||||
|
@ -179,7 +113,7 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
listView.setVerticalScrollBarEnabled(true);
|
||||
}
|
||||
if (emptyTextView != null) {
|
||||
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,51 +122,69 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
searching = 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);
|
||||
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
||||
fragmentView = new FrameLayout(getParentActivity());
|
||||
|
||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
||||
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() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
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() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
if (i < 0) {
|
||||
return;
|
||||
}
|
||||
Country country = null;
|
||||
if (searching && searchWas) {
|
||||
if (i >= 0 && i < searchResult.size()) {
|
||||
Country c = searchResult.get(i);
|
||||
if (delegate != null) {
|
||||
delegate.didSelectCountry(c.name);
|
||||
}
|
||||
finishFragment();
|
||||
}
|
||||
country = searchListViewAdapter.getItem(i);
|
||||
} else {
|
||||
int section = listViewAdapter.getSectionForPosition(i);
|
||||
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
||||
if (section >= 0 && section < sortedCountries.size()) {
|
||||
String n = sortedCountries.get(section);
|
||||
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();
|
||||
}
|
||||
if (row < 0 || section < 0) {
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
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.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
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.File;
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
@ -28,6 +29,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
|
@ -46,11 +48,11 @@ import org.telegram.android.MessagesController;
|
|||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Adapters.BaseSectionsAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.ContactsAdapter;
|
||||
import org.telegram.ui.Adapters.ContactsSearchAdapter;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.SectionsListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -87,7 +89,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
private TextView emptyTextView;
|
||||
private EditText userSelectEditText;
|
||||
private SectionsListView listView;
|
||||
private ContactsActivitySearchAdapter searchListViewAdapter;
|
||||
private ContactsSearchAdapter searchListViewAdapter;
|
||||
|
||||
private int beforeChangeIndex;
|
||||
private int maxCount = 200;
|
||||
|
@ -160,85 +162,17 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
|
||||
doneTextView.setText(LocaleController.getString("Next", R.string.Next));
|
||||
|
||||
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), null, false);
|
||||
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), true, false, null);
|
||||
|
||||
/*
|
||||
|
||||
|
||||
<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"/>
|
||||
|
||||
|
||||
*/
|
||||
searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
|
||||
listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
|
||||
searchListViewAdapter.setUseUserCell(true);
|
||||
|
||||
fragmentView = new LinearLayout(getParentActivity());
|
||||
LinearLayout linearLayout = (LinearLayout) fragmentView;
|
||||
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());
|
||||
linearLayout.addView(frameLayout);
|
||||
layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.TOP;
|
||||
|
@ -246,7 +180,23 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
|
||||
userSelectEditText = new EditText(getParentActivity());
|
||||
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.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));
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
|
@ -301,24 +251,59 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
if (search) {
|
||||
String text = userSelectEditText.getText().toString().replace("<", "");
|
||||
if (text.length() != 0) {
|
||||
searchDialogs(text);
|
||||
searching = true;
|
||||
searchWas = true;
|
||||
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
if (listView != null) {
|
||||
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 {
|
||||
searchResult = null;
|
||||
searchResultNames = null;
|
||||
searchListViewAdapter.searchDialogs(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||
ViewGroup group = (ViewGroup) listView.getParent();
|
||||
listView.setAdapter(listViewAdapter);
|
||||
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.setEmptyView(emptyTextView);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
|
@ -331,7 +316,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
listView.setFastScrollAlwaysVisible(true);
|
||||
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.width = 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() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
TLRPC.User user;
|
||||
/*TLRPC.User user;
|
||||
int section = listViewAdapter.getSectionForPosition(i);
|
||||
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
||||
if (searching && searchWas) {
|
||||
|
@ -387,7 +372,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
listViewAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
});
|
||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -18,7 +17,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
@ -30,22 +29,20 @@ import org.telegram.messenger.FileLog;
|
|||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||
import org.telegram.ui.Views.SettingsSectionLayout;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
|
||||
private PinnedHeaderListView listView;
|
||||
private ListView listView;
|
||||
private EditText nameTextView;
|
||||
private TLRPC.FileLocation avatar;
|
||||
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);
|
||||
|
||||
final ImageButton button2 = (ImageButton)fragmentView.findViewById(R.id.settings_change_avatar_button);
|
||||
if (isBroadcast) {
|
||||
button2.setVisibility(View.GONE);
|
||||
} else {
|
||||
button2.setOnClickListener(new View.OnClickListener() {
|
||||
if (!isBroadcast) {
|
||||
/*button2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (getParentActivity() == null) {
|
||||
|
@ -221,7 +215,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
});
|
||||
showAlertDialog(builder);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
|
||||
|
@ -238,7 +232,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
nameTextView.setText(nameToSet);
|
||||
nameToSet = null;
|
||||
}
|
||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||
listView.setAdapter(new ListAdapter(getParentActivity()));
|
||||
} else {
|
||||
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;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int section, int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return false;
|
||||
|
@ -369,61 +358,22 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int section, int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSectionCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCountForSection(int section) {
|
||||
if (selectedContacts == null) {
|
||||
return 0;
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(i));
|
||||
if (view == null) {
|
||||
view = new UserCell(mContext, 1);
|
||||
}
|
||||
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) {
|
||||
convertView = new SettingsSectionLayout(mContext);
|
||||
convertView.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
((SettingsSectionLayout) convertView).setText(LocaleController.formatPluralString("Members", selectedContacts.size()).toUpperCase());
|
||||
return convertView;
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.telegram.android.LocaleController;
|
|||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.IdenticonDrawable;
|
||||
|
||||
public class IdenticonActivity extends BaseFragment {
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.telegram.ui;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -18,6 +19,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -27,10 +29,11 @@ import org.telegram.android.LocaleController;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
|
@ -50,6 +53,9 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBar.setTitle(LocaleController.getString("Language", R.string.Language));
|
||||
|
@ -90,32 +96,46 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
if (listView != null) {
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
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());
|
||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||
listView.setAdapter(listAdapter);
|
||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||
listView.setEmptyView(emptyTextView);
|
||||
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
||||
|
||||
fragmentView = new FrameLayout(getParentActivity());
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
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() {
|
||||
@Override
|
||||
|
@ -192,9 +212,6 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
}
|
||||
});
|
||||
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
} else {
|
||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
|
@ -316,19 +333,11 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
@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.settings_row_button_layout, viewGroup, false);
|
||||
view = new TextSettingsCell(mContext);
|
||||
}
|
||||
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);
|
||||
textView.setText(c.name);
|
||||
if (i == searchResult.size() - 1) {
|
||||
divider.setVisibility(View.GONE);
|
||||
} else {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
((TextSettingsCell) view).setText(c.name, i != searchResult.size() - 1);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -392,19 +401,11 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
@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.settings_row_button_layout, viewGroup, false);
|
||||
view = new TextSettingsCell(mContext);
|
||||
}
|
||||
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);
|
||||
textView.setText(localeInfo.name);
|
||||
if (i == LocaleController.getInstance().sortedLanguages.size() - 1) {
|
||||
divider.setVisibility(View.GONE);
|
||||
} else {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
((TextSettingsCell) view).setText(localeInfo.name, i != LocaleController.getInstance().sortedLanguages.size() - 1);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -50,9 +50,9 @@ import org.telegram.messenger.TLRPC;
|
|||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.DrawerLayoutAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ActionBar.DrawerLayoutContainer;
|
||||
import org.telegram.ui.ActionBar.ActionBarLayout;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.DrawerLayoutContainer;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
|
@ -361,7 +361,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
}
|
||||
}
|
||||
} else if (fragmentName.equals("wallpapers")) {
|
||||
SettingsWallpapersActivity settings = new SettingsWallpapersActivity();
|
||||
WallpapersActivity settings = new WallpapersActivity();
|
||||
actionBarLayout.addFragmentToStack(settings);
|
||||
settings.restoreSelfArgs(savedInstanceState);
|
||||
}
|
||||
|
@ -1007,7 +1007,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
} else if (lastFragment instanceof GroupCreateFinalActivity && args != null) {
|
||||
outState.putBundle("args", args);
|
||||
outState.putString("fragment", "group");
|
||||
} else if (lastFragment instanceof SettingsWallpapersActivity) {
|
||||
} else if (lastFragment instanceof WallpapersActivity) {
|
||||
outState.putString("fragment", "wallpapers");
|
||||
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
|
||||
outState.putBundle("args", args);
|
||||
|
|
|
@ -35,12 +35,12 @@ import org.telegram.android.MessageObject;
|
|||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ import org.telegram.android.AndroidUtilities;
|
|||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
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.SlideView;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -42,10 +42,284 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
|
|||
|
||||
private final static int done_button = 1;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
return super.onFragmentCreate();
|
||||
}
|
||||
/*
|
||||
<ScrollView
|
||||
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
|
||||
public void onFragmentDestroy() {
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.telegram.messenger.ConnectionsManager;
|
|||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
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 java.io.BufferedReader;
|
||||
|
|
|
@ -33,9 +33,9 @@ import org.telegram.android.MessagesController;
|
|||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
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.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -40,24 +40,24 @@ import org.telegram.android.NotificationCenter;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Adapters.MessagesActivityAdapter;
|
||||
import org.telegram.ui.Adapters.MessagesActivitySearchAdapter;
|
||||
import org.telegram.ui.Adapters.DialogsAdapter;
|
||||
import org.telegram.ui.Adapters.DialogsSearchAdapter;
|
||||
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ActionBar.MenuDrawable;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.MenuDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MessagesActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
private ListView messagesListView;
|
||||
private MessagesActivityAdapter messagesActivityAdapter;
|
||||
private MessagesActivitySearchAdapter messagesActivitySearchAdapter;
|
||||
private DialogsAdapter dialogsAdapter;
|
||||
private DialogsSearchAdapter dialogsSearchAdapter;
|
||||
private TextView searchEmptyView;
|
||||
private View progressView;
|
||||
private View emptyView;
|
||||
|
@ -158,13 +158,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
ViewProxy.setTranslationY(floatingButton, AndroidUtilities.dp(100));
|
||||
hideFloatingButton(false);
|
||||
}
|
||||
if (messagesListView.getAdapter() != messagesActivityAdapter) {
|
||||
messagesListView.setAdapter(messagesActivityAdapter);
|
||||
messagesActivityAdapter.notifyDataSetChanged();
|
||||
if (messagesListView.getAdapter() != dialogsAdapter) {
|
||||
messagesListView.setAdapter(dialogsAdapter);
|
||||
dialogsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
if (messagesActivitySearchAdapter != null) {
|
||||
messagesActivitySearchAdapter.searchDialogs(null, false);
|
||||
if (dialogsSearchAdapter != null) {
|
||||
dialogsSearchAdapter.searchDialogs(null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,9 +173,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
String text = editText.getText().toString();
|
||||
if (text.length() != 0) {
|
||||
searchWas = true;
|
||||
if (messagesActivitySearchAdapter != null) {
|
||||
messagesListView.setAdapter(messagesActivitySearchAdapter);
|
||||
messagesActivitySearchAdapter.notifyDataSetChanged();
|
||||
if (dialogsSearchAdapter != null) {
|
||||
messagesListView.setAdapter(dialogsSearchAdapter);
|
||||
dialogsSearchAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (searchEmptyView != null && messagesListView.getEmptyView() == emptyView) {
|
||||
messagesListView.setEmptyView(searchEmptyView);
|
||||
|
@ -183,8 +183,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
progressView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (messagesActivitySearchAdapter != null) {
|
||||
messagesActivitySearchAdapter.searchDialogs(text, serverOnly);
|
||||
if (dialogsSearchAdapter != null) {
|
||||
dialogsSearchAdapter.searchDialogs(text, serverOnly);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -215,9 +215,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
|
||||
|
||||
messagesActivityAdapter = new MessagesActivityAdapter(getParentActivity(), serverOnly);
|
||||
messagesActivitySearchAdapter = new MessagesActivitySearchAdapter(getParentActivity());
|
||||
messagesActivitySearchAdapter.setDelegate(new MessagesActivitySearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
||||
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
|
||||
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity());
|
||||
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
||||
@Override
|
||||
public void searchStateChanged(boolean search) {
|
||||
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.setAdapter(messagesActivityAdapter);
|
||||
messagesListView.setAdapter(dialogsAdapter);
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
messagesListView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
||||
}
|
||||
|
||||
progressView = fragmentView.findViewById(R.id.progressLayout);
|
||||
messagesActivityAdapter.notifyDataSetChanged();
|
||||
dialogsAdapter.notifyDataSetChanged();
|
||||
searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
|
@ -295,17 +295,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
long dialog_id = 0;
|
||||
int message_id = 0;
|
||||
BaseFragmentAdapter adapter = (BaseFragmentAdapter)messagesListView.getAdapter();
|
||||
if (adapter == messagesActivityAdapter) {
|
||||
TLRPC.TL_dialog dialog = messagesActivityAdapter.getItem(i);
|
||||
if (adapter == dialogsAdapter) {
|
||||
TLRPC.TL_dialog dialog = dialogsAdapter.getItem(i);
|
||||
if (dialog == null) {
|
||||
return;
|
||||
}
|
||||
dialog_id = dialog.id;
|
||||
} else if (adapter == messagesActivitySearchAdapter) {
|
||||
Object obj = messagesActivitySearchAdapter.getItem(i);
|
||||
} else if (adapter == dialogsSearchAdapter) {
|
||||
Object obj = dialogsSearchAdapter.getItem(i);
|
||||
if (obj instanceof TLRPC.User) {
|
||||
dialog_id = ((TLRPC.User) obj).id;
|
||||
if (messagesActivitySearchAdapter.isGlobalSearch(i)) {
|
||||
if (dialogsSearchAdapter.isGlobalSearch(i)) {
|
||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
users.add((TLRPC.User)obj);
|
||||
MessagesController.getInstance().putUsers(users, false);
|
||||
|
@ -356,7 +356,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
if (openedDialogId == dialog_id) {
|
||||
return;
|
||||
}
|
||||
messagesActivityAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
||||
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
||||
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
||||
}
|
||||
presentFragment(new ChatActivity(args));
|
||||
|
@ -501,11 +501,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (messagesActivityAdapter != null) {
|
||||
messagesActivityAdapter.notifyDataSetChanged();
|
||||
if (dialogsAdapter != null) {
|
||||
dialogsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (messagesActivitySearchAdapter != null) {
|
||||
messagesActivitySearchAdapter.notifyDataSetChanged();
|
||||
if (dialogsSearchAdapter != null) {
|
||||
dialogsSearchAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,8 +533,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
@SuppressWarnings("unchecked")
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == NotificationCenter.dialogsNeedReload) {
|
||||
if (messagesActivityAdapter != null) {
|
||||
messagesActivityAdapter.notifyDataSetChanged();
|
||||
if (dialogsAdapter != null) {
|
||||
dialogsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (messagesListView != null) {
|
||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||
|
@ -577,7 +577,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
} else {
|
||||
openedDialogId = dialog_id;
|
||||
}
|
||||
messagesActivityAdapter.setOpenedDialogId(openedDialogId);
|
||||
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
||||
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.TextColorCell;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
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 boolean reseting = false;
|
||||
|
|
@ -20,16 +20,16 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
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;
|
||||
|
||||
|
@ -282,6 +282,8 @@ public class PhotoCropActivity extends BaseFragment {
|
|||
private boolean sameBitmap = false;
|
||||
private boolean doneButtonPressed = false;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
public PhotoCropActivity(Bundle args) {
|
||||
super(args);
|
||||
}
|
||||
|
@ -328,33 +330,30 @@ public class PhotoCropActivity extends BaseFragment {
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBar.setTitle(LocaleController.getString("AddContact", R.string.AddContact));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
View doneButton = actionBar.findViewById(R.id.done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (delegate != null && !doneButtonPressed) {
|
||||
Bitmap bitmap = view.getBitmap();
|
||||
if (bitmap == imageToCrop) {
|
||||
sameBitmap = true;
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == done_button) {
|
||||
if (delegate != null && !doneButtonPressed) {
|
||||
Bitmap bitmap = view.getBitmap();
|
||||
if (bitmap == imageToCrop) {
|
||||
sameBitmap = true;
|
||||
}
|
||||
delegate.didFinishCrop(bitmap);
|
||||
doneButtonPressed = true;
|
||||
}
|
||||
delegate.didFinishCrop(bitmap);
|
||||
doneButtonPressed = true;
|
||||
finishFragment();
|
||||
}
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||
textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
menu.addItem(done_button, R.drawable.ic_done);
|
||||
|
||||
fragmentView = view = new PhotoCropView(getParentActivity());
|
||||
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.android.MessageObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
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.BackupImageView;
|
||||
|
||||
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.ObjectAnimatorProxy;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.ClippingImageView;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.PhotoObject;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
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.TextDetailCell;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
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 java.util.ArrayList;
|
||||
|
@ -325,7 +325,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
} else if (id == edit_name) {
|
||||
Bundle args = new Bundle();
|
||||
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.Cells.TextColorCell;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
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.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
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 java.io.File;
|
||||
|
@ -274,7 +274,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == edit_name) {
|
||||
presentFragment(new SettingsChangeNameActivity());
|
||||
presentFragment(new ChangeNameActivity());
|
||||
} else if (id == logout) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
|
@ -424,11 +424,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
listView.invalidateViews();
|
||||
}
|
||||
} else if (i == notificationRow) {
|
||||
presentFragment(new SettingsNotificationsActivity());
|
||||
presentFragment(new NotificationsSettingsActivity());
|
||||
} else if (i == blockedRow) {
|
||||
presentFragment(new SettingsBlockedUsersActivity());
|
||||
presentFragment(new BlockedUsersActivity());
|
||||
} else if (i == backgroundRow) {
|
||||
presentFragment(new SettingsWallpapersActivity());
|
||||
presentFragment(new WallpapersActivity());
|
||||
} else if (i == askQuestionRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
|
@ -627,7 +627,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
||||
showAlertDialog(builder);
|
||||
} 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.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
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.VideoSeekBarView;
|
||||
import org.telegram.ui.Views.VideoTimelineView;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.PhotoCropActivity;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
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.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
|
@ -200,16 +199,4 @@ public class SectionsListView extends ListView implements AbsListView.OnScrollLi
|
|||
public void setOnItemClickListener(SectionsListView.OnItemClickListener listener) {
|
||||
super.setOnItemClickListener(listener);
|
||||
}
|
||||
|
||||
public static abstract class OnItemClickListener implements AdapterView.OnItemClickListener {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
|
||||
SectionedBaseAdapter adapter = (SectionedBaseAdapter) adapterView.getAdapter();
|
||||
int section = adapter.getSectionForPosition(rawPosition);
|
||||
int position = adapter.getPositionInSectionForPosition(rawPosition);
|
||||
onItemClick(adapterView, view, section, position, id);
|
||||
}
|
||||
|
||||
public abstract void onItemClick(AdapterView<?> adapterView, View view, int section, int position, long id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,7 +360,6 @@ public class Switch extends CompoundButton {
|
|||
final float targetPosition = newCheckedState ? 1 : 0;
|
||||
mPositionAnimator = ObjectAnimatorProxy.ofFloatProxy(this, "thumbPosition", targetPosition);
|
||||
mPositionAnimator.setDuration(THUMB_ANIMATION_DURATION);
|
||||
mPositionAnimator.setAutoCancel(true);
|
||||
mPositionAnimator.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageLoader;
|
||||
|
@ -45,8 +43,10 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
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.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.HorizontalListView;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -54,7 +54,8 @@ import java.io.FileOutputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SettingsWallpapersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
public class WallpapersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private HorizontalListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private ImageView backgroundImage;
|
||||
|
@ -69,6 +70,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
private TLRPC.PhotoSize loadingSize = null;
|
||||
private String currentPicturePath;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
|
@ -99,63 +102,60 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
||||
Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBar.setTitle(LocaleController.getString("ChatBackground", R.string.ChatBackground));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
doneButton = actionBar.findViewById(R.id.done_button);
|
||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean done;
|
||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||
int width = AndroidUtilities.displaySize.x;
|
||||
int height = AndroidUtilities.displaySize.y;
|
||||
if (width > height) {
|
||||
int temp = width;
|
||||
width = height;
|
||||
height = temp;
|
||||
}
|
||||
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");
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == done_button) {
|
||||
boolean done;
|
||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||
int width = AndroidUtilities.displaySize.x;
|
||||
int height = AndroidUtilities.displaySize.y;
|
||||
if (width > height) {
|
||||
int temp = width;
|
||||
width = height;
|
||||
height = temp;
|
||||
}
|
||||
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");
|
||||
done = fromFile.renameTo(toFile);
|
||||
try {
|
||||
done = Utilities.copyFile(f, toFile);
|
||||
} catch (Exception e) {
|
||||
done = false;
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} 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) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("selectedBackground", selectedBackground);
|
||||
editor.putInt("selectedColor", selectedColor);
|
||||
editor.commit();
|
||||
ApplicationLoader.cachedWallpaper = null;
|
||||
if (done) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("selectedBackground", selectedBackground);
|
||||
editor.putInt("selectedColor", selectedColor);
|
||||
editor.commit();
|
||||
ApplicationLoader.cachedWallpaper = null;
|
||||
}
|
||||
finishFragment();
|
||||
}
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
|
||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||
textView.setText(LocaleController.getString("Set", R.string.Set).toUpperCase());
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItem(done_button, R.drawable.ic_done);
|
||||
|
||||
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
|
||||
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 |