Implemented own ActionBar and Fragments, swipe back navigation, https://github.com/DrKLO/Telegram/issues/424
@ -82,7 +82,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 233
|
versionCode 234
|
||||||
versionName "1.4.14"
|
versionName "1.4.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,19 +95,6 @@
|
|||||||
<data android:mimeType="vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"/>
|
<data android:mimeType="vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name="org.telegram.ui.LoginActivity"
|
|
||||||
android:windowSoftInputMode="adjustResize"
|
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
|
||||||
android:screenOrientation="portrait">
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name="org.telegram.ui.CountrySelectActivity"
|
|
||||||
android:windowSoftInputMode="adjustResize"
|
|
||||||
android:theme="@style/Theme.TMessages"
|
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
|
||||||
android:screenOrientation="portrait">
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.telegram.ui.IntroActivity"
|
android:name="org.telegram.ui.IntroActivity"
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||||
|
@ -456,6 +456,19 @@ public class LocaleController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatStringSimple(String string, Object... args) {
|
||||||
|
try {
|
||||||
|
if (getInstance().currentLocale != null) {
|
||||||
|
return String.format(getInstance().currentLocale, string, args);
|
||||||
|
} else {
|
||||||
|
return String.format(string, args);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
return "LOC_ERR: " + string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onDeviceConfigurationChange(Configuration newConfig) {
|
public void onDeviceConfigurationChange(Configuration newConfig) {
|
||||||
if (changingConfiguration) {
|
if (changingConfiguration) {
|
||||||
return;
|
return;
|
||||||
|
@ -564,9 +564,11 @@ public class MessagesStorage {
|
|||||||
}
|
}
|
||||||
ids += uid;
|
ids += uid;
|
||||||
}
|
}
|
||||||
|
int totalCount = 0;
|
||||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT uid, read_state, out FROM messages WHERE mid IN(%s)", ids));
|
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT uid, read_state, out FROM messages WHERE mid IN(%s)", ids));
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
int out = cursor.intValue(2);
|
int out = cursor.intValue(2);
|
||||||
|
totalCount++;
|
||||||
if (out != 0) {
|
if (out != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -588,6 +590,10 @@ public class MessagesStorage {
|
|||||||
}
|
}
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
|
||||||
|
if (totalCount != messages.size()) {
|
||||||
|
FileLog.e("tmessages", "messages read mismatch!");
|
||||||
|
}
|
||||||
|
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT did, unread_count FROM dialogs WHERE did IN(%s)", dialogsToReload));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT did, unread_count FROM dialogs WHERE did IN(%s)", dialogsToReload));
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
long did = cursor.longValue(0);
|
long did = cursor.longValue(0);
|
||||||
|
@ -205,7 +205,7 @@ public class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int dp(int value) {
|
public static int dp(int value) {
|
||||||
return (int)(density * value);
|
return (int)(Math.max(1, density * value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int dpf(float value) {
|
public static int dpf(float value) {
|
||||||
|
@ -24,7 +24,6 @@ import android.graphics.Bitmap;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.view.ViewConfiguration;
|
|
||||||
|
|
||||||
import com.google.android.gms.common.ConnectionResult;
|
import com.google.android.gms.common.ConnectionResult;
|
||||||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
import com.google.android.gms.common.GooglePlayServicesUtil;
|
||||||
@ -41,10 +40,7 @@ import org.telegram.messenger.NativeLoader;
|
|||||||
import org.telegram.messenger.ScreenReceiver;
|
import org.telegram.messenger.ScreenReceiver;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -64,8 +60,6 @@ public class ApplicationLoader extends Application {
|
|||||||
private static volatile boolean applicationInited = false;
|
private static volatile boolean applicationInited = false;
|
||||||
public static volatile boolean isScreenOn = false;
|
public static volatile boolean isScreenOn = false;
|
||||||
|
|
||||||
public static ArrayList<BaseFragment> fragmentsStack = new ArrayList<BaseFragment>();
|
|
||||||
|
|
||||||
public static void postInitApplication() {
|
public static void postInitApplication() {
|
||||||
if (applicationInited) {
|
if (applicationInited) {
|
||||||
return;
|
return;
|
||||||
@ -149,17 +143,6 @@ public class ApplicationLoader extends Application {
|
|||||||
java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
|
java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
|
||||||
java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
|
java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
|
||||||
|
|
||||||
try {
|
|
||||||
ViewConfiguration config = ViewConfiguration.get(this);
|
|
||||||
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
|
|
||||||
if(menuKeyField != null) {
|
|
||||||
menuKeyField.setAccessible(true);
|
|
||||||
menuKeyField.setBoolean(config, false);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
startPushService();
|
startPushService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import org.telegram.messenger.R;
|
|||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.objects.MessageObject;
|
import org.telegram.objects.MessageObject;
|
||||||
import org.telegram.ui.Views.ImageReceiver;
|
import org.telegram.ui.Views.ImageReceiver;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
@ -41,8 +40,6 @@ public class ChatBaseCell extends BaseCell {
|
|||||||
public abstract void didPressedCancelSendButton(ChatBaseCell cell);
|
public abstract void didPressedCancelSendButton(ChatBaseCell cell);
|
||||||
public abstract void didLongPressed(ChatBaseCell cell);
|
public abstract void didLongPressed(ChatBaseCell cell);
|
||||||
public abstract boolean canPerformActions();
|
public abstract boolean canPerformActions();
|
||||||
public boolean onSwipeLeft();
|
|
||||||
public boolean onSwipeRight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChat = false;
|
public boolean isChat = false;
|
||||||
@ -118,7 +115,6 @@ public class ChatBaseCell extends BaseCell {
|
|||||||
private int pressCount = 0;
|
private int pressCount = 0;
|
||||||
private CheckForLongPress pendingCheckForLongPress = null;
|
private CheckForLongPress pendingCheckForLongPress = null;
|
||||||
private CheckForTap pendingCheckForTap = null;
|
private CheckForTap pendingCheckForTap = null;
|
||||||
private OnSwipeTouchListener onSwipeTouchListener;
|
|
||||||
|
|
||||||
private final class CheckForTap implements Runnable {
|
private final class CheckForTap implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -153,23 +149,6 @@ public class ChatBaseCell extends BaseCell {
|
|||||||
media = isMedia;
|
media = isMedia;
|
||||||
avatarImage = new ImageReceiver();
|
avatarImage = new ImageReceiver();
|
||||||
avatarImage.parentView = new WeakReference<View>(this);
|
avatarImage.parentView = new WeakReference<View>(this);
|
||||||
onSwipeTouchListener = new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
if (delegate != null && delegate.onSwipeRight()) {
|
|
||||||
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
|
|
||||||
onTouchEvent(event);
|
|
||||||
event.recycle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSwipeLeft() {
|
|
||||||
if (delegate != null && delegate.onSwipeLeft()) {
|
|
||||||
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
|
|
||||||
onTouchEvent(event);
|
|
||||||
event.recycle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -384,10 +363,6 @@ public class ChatBaseCell extends BaseCell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkSwipes(MotionEvent event) {
|
|
||||||
onSwipeTouchListener.onTouch(this, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
@ -135,7 +135,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
int side = Utilities.dp(44);
|
int side = Utilities.dp(44);
|
||||||
checkSwipes(event);
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
if (delegate == null || delegate.canPerformActions()) {
|
if (delegate == null || delegate.canPerformActions()) {
|
||||||
if (buttonState != -1 && x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side) {
|
if (buttonState != -1 && x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side) {
|
||||||
|
@ -482,7 +482,7 @@ public class DialogCell extends BaseCell {
|
|||||||
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#316f9f>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#316f9f>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
||||||
} else {
|
} else {
|
||||||
if (message.messageOwner.message != null) {
|
if (message.messageOwner.message != null) {
|
||||||
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " "))), messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,13 +20,8 @@ import android.media.RingtoneManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -45,10 +40,11 @@ import org.telegram.messenger.R;
|
|||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.AvatarUpdater;
|
import org.telegram.ui.Views.AvatarUpdater;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -79,6 +75,12 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
private int leaveGroupRow;
|
private int leaveGroupRow;
|
||||||
private int rowCount = 0;
|
private int rowCount = 0;
|
||||||
|
|
||||||
|
private static final int done_button = 1;
|
||||||
|
|
||||||
|
public ChatProfileActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
@ -140,19 +142,31 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
avatarUpdater.clear();
|
avatarUpdater.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
} else if (id == done_button) {
|
||||||
|
openAddMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
View item = menu.addItemResource(done_button, R.layout.group_profile_add_member_layout);
|
||||||
|
TextView textView = (TextView)item.findViewById(R.id.done_button);
|
||||||
|
if (textView != null) {
|
||||||
|
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
|
||||||
|
}
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.chat_profile_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.chat_profile_layout, container, false);
|
||||||
|
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setAdapter(listViewAdapter = new ListAdapter(parentActivity));
|
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
|
||||||
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
@ -166,7 +180,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
selectedUser = user;
|
selectedUser = user;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
CharSequence[] items = new CharSequence[] {LocaleController.getString("KickFromGroup", R.string.KickFromGroup)};
|
CharSequence[] items = new CharSequence[] {LocaleController.getString("KickFromGroup", R.string.KickFromGroup)};
|
||||||
|
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
@ -188,16 +202,13 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (i == settingsSoundRow) {
|
if (i == settingsSoundRow) {
|
||||||
try {
|
try {
|
||||||
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
||||||
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
Uri currentSound = null;
|
Uri currentSound = null;
|
||||||
|
|
||||||
String defaultPath = null;
|
String defaultPath = null;
|
||||||
@ -216,16 +227,14 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||||
parentActivity.startActivityForResult(tmpIntent, 3);
|
getParentActivity().startActivityForResult(tmpIntent, 3);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
} else if (i == sharedMediaRow) {
|
} else if (i == sharedMediaRow) {
|
||||||
MediaActivity fragment = new MediaActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putLong("dialog_id", -chat_id);
|
||||||
bundle.putLong("dialog_id", -chat_id);
|
presentFragment(new MediaActivity(args));
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "media_chat_" + chat_id, false);
|
|
||||||
} else if (i == addMemberRow) {
|
} else if (i == addMemberRow) {
|
||||||
openAddMenu();
|
openAddMenu();
|
||||||
} else if (i > membersSectionRow && i < addMemberRow) {
|
} else if (i > membersSectionRow && i < addMemberRow) {
|
||||||
@ -233,13 +242,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if (user_id == UserConfig.clientUserId) {
|
if (user_id == UserConfig.clientUserId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UserProfileActivity fragment = new UserProfileActivity();
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", user_id);
|
args.putInt("user_id", user_id);
|
||||||
fragment.setArguments(args);
|
presentFragment(new UserProfileActivity(args));
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "user_" + user_id, false);
|
|
||||||
} else if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
} else if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
LocaleController.getString("Default", R.string.Default),
|
LocaleController.getString("Default", R.string.Default),
|
||||||
@ -266,12 +273,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -293,19 +294,19 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if (requestCode == 3) {
|
if (requestCode == 3) {
|
||||||
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||||
String name = null;
|
String name = null;
|
||||||
if (ringtone != null && parentActivity != null) {
|
if (ringtone != null) {
|
||||||
Ringtone rng = RingtoneManager.getRingtone(parentActivity, ringtone);
|
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
|
||||||
if (rng != null) {
|
if (rng != null) {
|
||||||
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||||
name = LocaleController.getString("Default", R.string.Default);
|
name = LocaleController.getString("Default", R.string.Default);
|
||||||
} else {
|
} else {
|
||||||
name = rng.getTitle(parentActivity);
|
name = rng.getTitle(getParentActivity());
|
||||||
}
|
}
|
||||||
rng.stop();
|
rng.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
if (name != null && ringtone != null) {
|
if (name != null && ringtone != null) {
|
||||||
@ -321,6 +322,20 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSelfArgs(Bundle args) {
|
||||||
|
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
|
||||||
|
args.putString("path", avatarUpdater.currentPicturePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreSelfArgs(Bundle args) {
|
||||||
|
if (avatarUpdater != null) {
|
||||||
|
avatarUpdater.currentPicturePath = args.getString("path");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void didReceivedNotification(int id, Object... args) {
|
public void didReceivedNotification(int id, Object... args) {
|
||||||
if (id == MessagesController.updateInterfaces) {
|
if (id == MessagesController.updateInterfaces) {
|
||||||
int mask = (Integer)args[0];
|
int mask = (Integer)args[0];
|
||||||
@ -354,55 +369,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (listViewAdapter != null) {
|
if (listViewAdapter != null) {
|
||||||
listViewAdapter.notifyDataSetChanged();
|
listViewAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVisibleRows(int mask) {
|
private void updateVisibleRows(int mask) {
|
||||||
@ -467,14 +438,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
|
|
||||||
private void processPhotoMenu(int action) {
|
private void processPhotoMenu(int action) {
|
||||||
if (action == 0) {
|
if (action == 0) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
|
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
|
||||||
if (chat.photo != null && chat.photo.photo_big != null) {
|
if (chat.photo != null && chat.photo.photo_big != null) {
|
||||||
NotificationCenter.getInstance().addToMemCache(53, chat.photo.photo_big);
|
NotificationCenter.getInstance().addToMemCache(53, chat.photo.photo_big);
|
||||||
Intent intent = new Intent(parentActivity, GalleryImageViewer.class);
|
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
} else if (action == 1) {
|
} else if (action == 1) {
|
||||||
avatarUpdater.openCamera();
|
avatarUpdater.openCamera();
|
||||||
@ -486,25 +454,22 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openAddMenu() {
|
private void openAddMenu() {
|
||||||
ContactsActivity fragment = new ContactsActivity();
|
Bundle args = new Bundle();
|
||||||
fragment.animationType = 1;
|
args.putBoolean("onlyUsers", true);
|
||||||
Bundle bundle = new Bundle();
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
bundle.putBoolean("onlyUsers", true);
|
args.putBoolean("usersAsSections", true);
|
||||||
bundle.putBoolean("destroyAfterSelect", true);
|
args.putBoolean("returnAsResult", true);
|
||||||
bundle.putBoolean("usersAsSections", true);
|
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
|
||||||
bundle.putBoolean("returnAsResult", true);
|
ContactsActivity fragment = new ContactsActivity(args);
|
||||||
fragment.selectAlertString = R.string.AddToTheGroup;
|
fragment.setDelegate(this);
|
||||||
fragment.selectAlertStringDesc = "AddToTheGroup";
|
|
||||||
fragment.delegate = this;
|
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
HashMap<Integer, TLRPC.User> users = new HashMap<Integer, TLRPC.User>();
|
HashMap<Integer, TLRPC.User> users = new HashMap<Integer, TLRPC.User>();
|
||||||
for (TLRPC.TL_chatParticipant p : info.participants) {
|
for (TLRPC.TL_chatParticipant p : info.participants) {
|
||||||
users.put(p.user_id, null);
|
users.put(p.user_id, null);
|
||||||
}
|
}
|
||||||
NotificationCenter.getInstance().addToMemCache(7, users);
|
fragment.setIgnoreUsers(users);
|
||||||
}
|
}
|
||||||
fragment.setArguments(bundle);
|
presentFragment(fragment);
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "contacts_block", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void kickUser(TLRPC.TL_chatParticipant user) {
|
private void kickUser(TLRPC.TL_chatParticipant user) {
|
||||||
@ -519,25 +484,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
SupportMenuItem item = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, LocaleController.getString("AddMember", R.string.AddMember));
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
LayoutInflater li = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
item.setActionView(R.layout.group_profile_add_member_layout);
|
|
||||||
|
|
||||||
TextView textView = (TextView)item.getActionView().findViewById(R.id.done_button);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
|
|
||||||
textView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
openAddMenu();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ListAdapter extends BaseAdapter {
|
private class ListAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@ -591,11 +537,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
ChatProfileChangeNameActivity fragment = new ChatProfileChangeNameActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("chat_id", chat_id);
|
||||||
bundle.putInt("chat_id", chat_id);
|
presentFragment(new ChatProfileChangeNameActivity(args));
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat_name_" + chat_id, false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -603,7 +547,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
button2.setOnClickListener(new View.OnClickListener() {
|
button2.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
CharSequence[] items;
|
CharSequence[] items;
|
||||||
int type;
|
int type;
|
||||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
|
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
|
||||||
@ -647,6 +591,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
||||||
}
|
}
|
||||||
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||||
|
avatarImage.processDetach = false;
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_name);
|
TextView textView = (TextView)view.findViewById(R.id.settings_name);
|
||||||
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
||||||
textView.setTypeface(typeface);
|
textView.setTypeface(typeface);
|
||||||
@ -753,7 +698,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
textView.setOnClickListener(new View.OnClickListener() {
|
textView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
|
@ -11,13 +11,10 @@ package org.telegram.ui;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -28,7 +25,7 @@ import org.telegram.messenger.TLRPC;
|
|||||||
import org.telegram.messenger.MessagesController;
|
import org.telegram.messenger.MessagesController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class ChatProfileChangeNameActivity extends BaseFragment {
|
public class ChatProfileChangeNameActivity extends BaseFragment {
|
||||||
private EditText firstNameField;
|
private EditText firstNameField;
|
||||||
@ -36,8 +33,8 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
|||||||
private int chat_id;
|
private int chat_id;
|
||||||
private View doneButton;
|
private View doneButton;
|
||||||
|
|
||||||
public ChatProfileChangeNameActivity() {
|
public ChatProfileChangeNameActivity(Bundle args) {
|
||||||
animationType = 1;
|
super(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,18 +45,32 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onFragmentDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setCustomView(R.layout.settings_do_action_layout);
|
||||||
|
|
||||||
|
Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button);
|
||||||
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
doneButton = actionBarLayer.findViewById(R.id.done_button);
|
||||||
|
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (firstNameField.getText().length() != 0) {
|
||||||
|
saveName();
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
||||||
|
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||||
|
textView.setText(LocaleController.getString("Done", R.string.Done));
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false);
|
||||||
|
|
||||||
TLRPC.Chat currentChat = MessagesController.getInstance().chats.get(chat_id);
|
TLRPC.Chat currentChat = MessagesController.getInstance().chats.get(chat_id);
|
||||||
@ -90,54 +101,8 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canApplyUpdateStatus() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowCustomEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
|
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
|
||||||
Button cancelButton = (Button)actionBar.getCustomView().findViewById(R.id.cancel_button);
|
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = actionBar.getCustomView().findViewById(R.id.done_button);
|
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (firstNameField.getText().length() != 0) {
|
|
||||||
saveName();
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
boolean animations = preferences.getBoolean("view_animations", true);
|
boolean animations = preferences.getBoolean("view_animations", true);
|
||||||
if (!animations) {
|
if (!animations) {
|
||||||
@ -147,31 +112,9 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
public void onOpenAnimationEnd() {
|
||||||
if (nextAnim != 0) {
|
firstNameField.requestFocus();
|
||||||
Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
|
Utilities.showKeyboard(firstNameField);
|
||||||
|
|
||||||
anim.setAnimationListener(new Animation.AnimationListener() {
|
|
||||||
|
|
||||||
public void onAnimationStart(Animation animation) {
|
|
||||||
ChatProfileChangeNameActivity.this.onAnimationStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationRepeat(Animation animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationEnd(Animation animation) {
|
|
||||||
ChatProfileChangeNameActivity.this.onAnimationEnd();
|
|
||||||
firstNameField.requestFocus();
|
|
||||||
Utilities.showKeyboard(firstNameField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return anim;
|
|
||||||
} else {
|
|
||||||
return super.onCreateAnimation(transit, enter, nextAnim);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveName() {
|
private void saveName() {
|
||||||
|
@ -12,29 +12,25 @@ import android.app.Activity;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.PhoneFormat.PhoneFormat;
|
import org.telegram.PhoneFormat.PhoneFormat;
|
||||||
|
import org.telegram.messenger.ContactsController;
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
|
||||||
import org.telegram.messenger.ContactsController;
|
|
||||||
import org.telegram.messenger.MessagesController;
|
import org.telegram.messenger.MessagesController;
|
||||||
import org.telegram.messenger.NotificationCenter;
|
import org.telegram.messenger.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
private int user_id;
|
private int user_id;
|
||||||
@ -46,14 +42,17 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||||||
private TextView onlineText;
|
private TextView onlineText;
|
||||||
private TextView phoneText;
|
private TextView phoneText;
|
||||||
|
|
||||||
|
public ContactAddActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||||
user_id = getArguments().getInt("user_id", 0);
|
user_id = getArguments().getInt("user_id", 0);
|
||||||
phone = getArguments().getString("phone");
|
phone = getArguments().getString("phone");
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
return user != null;
|
return user != null && super.onFragmentCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,8 +62,35 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setCustomView(R.layout.settings_do_action_layout);
|
||||||
|
Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button);
|
||||||
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
doneButton = actionBarLayer.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().users.get(user_id);
|
||||||
|
user.first_name = firstNameField.getText().toString();
|
||||||
|
user.last_name = lastNameField.getText().toString();
|
||||||
|
ContactsController.getInstance().addContact(user);
|
||||||
|
finishFragment();
|
||||||
|
NotificationCenter.getInstance().postNotificationName(MessagesController.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
||||||
|
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||||
|
textView.setText(LocaleController.getString("Done", R.string.Done));
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false);
|
||||||
|
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
@ -149,68 +175,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canApplyUpdateStatus() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowCustomEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
|
||||||
Button cancelButton = (Button)actionBar.getCustomView().findViewById(R.id.cancel_button);
|
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = actionBar.getCustomView().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().users.get(user_id);
|
|
||||||
user.first_name = firstNameField.getText().toString();
|
|
||||||
user.last_name = lastNameField.getText().toString();
|
|
||||||
ContactsController.getInstance().addContact(user);
|
|
||||||
finishFragment();
|
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
boolean animations = preferences.getBoolean("view_animations", true);
|
boolean animations = preferences.getBoolean("view_animations", true);
|
||||||
if (!animations) {
|
if (!animations) {
|
||||||
@ -220,30 +186,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
public void onOpenAnimationEnd() {
|
||||||
if (nextAnim != 0) {
|
firstNameField.requestFocus();
|
||||||
Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
|
Utilities.showKeyboard(firstNameField);
|
||||||
|
|
||||||
anim.setAnimationListener(new Animation.AnimationListener() {
|
|
||||||
|
|
||||||
public void onAnimationStart(Animation animation) {
|
|
||||||
ContactAddActivity.this.onAnimationStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationRepeat(Animation animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationEnd(Animation animation) {
|
|
||||||
ContactAddActivity.this.onAnimationEnd();
|
|
||||||
firstNameField.requestFocus();
|
|
||||||
Utilities.showKeyboard(firstNameField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return anim;
|
|
||||||
} else {
|
|
||||||
return super.onCreateAnimation(transit, enter, nextAnim);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,19 +15,12 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ImageView;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
@ -45,13 +38,13 @@ import org.telegram.messenger.Utilities;
|
|||||||
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
import org.telegram.ui.Adapters.ContactsActivityAdapter;
|
||||||
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
import org.telegram.ui.Adapters.ContactsActivitySearchAdapter;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
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.PinnedHeaderListView;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -68,21 +61,22 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
private boolean returnAsResult;
|
private boolean returnAsResult;
|
||||||
private boolean createSecretChat;
|
private boolean createSecretChat;
|
||||||
private boolean creatingChat = false;
|
private boolean creatingChat = false;
|
||||||
public int selectAlertString = 0;
|
private String selectAlertString = null;
|
||||||
public String selectAlertStringDesc = null;
|
|
||||||
private SearchView searchView;
|
|
||||||
private TextView emptyTextView;
|
private TextView emptyTextView;
|
||||||
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
private HashMap<Integer, TLRPC.User> ignoreUsers;
|
||||||
private SupportMenuItem searchItem;
|
|
||||||
|
|
||||||
private String inviteText;
|
private String inviteText;
|
||||||
private boolean updatingInviteText = false;
|
private boolean updatingInviteText = false;
|
||||||
public ContactsActivityDelegate delegate;
|
private ContactsActivityDelegate delegate;
|
||||||
|
|
||||||
public static interface ContactsActivityDelegate {
|
public static interface ContactsActivityDelegate {
|
||||||
public abstract void didSelectContact(TLRPC.User user);
|
public abstract void didSelectContact(TLRPC.User user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ContactsActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
@ -90,18 +84,15 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatCreated);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatCreated);
|
||||||
if (getArguments() != null) {
|
if (arguments != null) {
|
||||||
onlyUsers = getArguments().getBoolean("onlyUsers", false);
|
onlyUsers = getArguments().getBoolean("onlyUsers", false);
|
||||||
destroyAfterSelect = getArguments().getBoolean("destroyAfterSelect", false);
|
destroyAfterSelect = getArguments().getBoolean("destroyAfterSelect", false);
|
||||||
usersAsSections = getArguments().getBoolean("usersAsSections", false);
|
usersAsSections = getArguments().getBoolean("usersAsSections", false);
|
||||||
returnAsResult = getArguments().getBoolean("returnAsResult", false);
|
returnAsResult = getArguments().getBoolean("returnAsResult", false);
|
||||||
createSecretChat = getArguments().getBoolean("createSecretChat", false);
|
createSecretChat = getArguments().getBoolean("createSecretChat", false);
|
||||||
if (destroyAfterSelect) {
|
selectAlertString = arguments.getString("selectAlertString");
|
||||||
ignoreUsers = (HashMap<Integer, TLRPC.User>)NotificationCenter.getInstance().getFromMemCache(7);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
inviteText = preferences.getString("invitetext", null);
|
inviteText = preferences.getString("invitetext", null);
|
||||||
int time = preferences.getInt("invitetexttime", 0);
|
int time = preferences.getInt("invitetexttime", 0);
|
||||||
@ -121,25 +112,77 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
delegate = null;
|
delegate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void willBeHidden() {
|
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
if (destroyAfterSelect) {
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
|
||||||
|
} else {
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("Contacts", R.string.Contacts));
|
||||||
|
}
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||||
|
@Override
|
||||||
|
public void onSearchExpand() {
|
||||||
|
searching = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchCollapse() {
|
||||||
|
searchListViewAdapter.searchDialogs(null);
|
||||||
|
searching = false;
|
||||||
|
searchWas = false;
|
||||||
|
ViewGroup group = (ViewGroup) listView.getParent();
|
||||||
|
listView.setAdapter(listViewAdapter);
|
||||||
|
if (!LocaleController.isRTL) {
|
||||||
|
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
|
||||||
|
} else {
|
||||||
|
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(EditText editText) {
|
||||||
|
if (searchListViewAdapter == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String text = editText.getText().toString();
|
||||||
|
if (text.length() != 0) {
|
||||||
|
searchWas = true;
|
||||||
|
if (listView != null) {
|
||||||
|
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
searchListViewAdapter.searchDialogs(text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
@ -148,13 +191,13 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
|
|
||||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||||
searchListViewAdapter = new ContactsActivitySearchAdapter(parentActivity, ignoreUsers);
|
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), ignoreUsers);
|
||||||
|
|
||||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setEmptyView(emptyTextView);
|
listView.setEmptyView(emptyTextView);
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
|
||||||
listViewAdapter = new ContactsActivityAdapter(parentActivity, onlyUsers, usersAsSections, ignoreUsers);
|
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, usersAsSections, ignoreUsers);
|
||||||
listView.setAdapter(listViewAdapter);
|
listView.setAdapter(listViewAdapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -172,13 +215,11 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
} else {
|
} else {
|
||||||
if (createSecretChat) {
|
if (createSecretChat) {
|
||||||
creatingChat = true;
|
creatingChat = true;
|
||||||
MessagesController.getInstance().startSecretChat(parentActivity, user);
|
MessagesController.getInstance().startSecretChat(getParentActivity(), user);
|
||||||
} else {
|
} else {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("user_id", user.id);
|
||||||
bundle.putInt("user_id", user.id);
|
presentFragment(new ChatActivity(args), true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), destroyAfterSelect, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -205,7 +246,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, inviteText != null ? inviteText : LocaleController.getString("InviteText", R.string.InviteText));
|
intent.putExtra(Intent.EXTRA_TEXT, inviteText != null ? inviteText : LocaleController.getString("InviteText", R.string.InviteText));
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
@ -232,13 +273,11 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
} else {
|
} else {
|
||||||
if (createSecretChat) {
|
if (createSecretChat) {
|
||||||
creatingChat = true;
|
creatingChat = true;
|
||||||
MessagesController.getInstance().startSecretChat(parentActivity, user);
|
MessagesController.getInstance().startSecretChat(getParentActivity(), user);
|
||||||
} else {
|
} else {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("user_id", user.id);
|
||||||
bundle.putInt("user_id", user.id);
|
presentFragment(new ChatActivity(args), true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), destroyAfterSelect, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -251,7 +290,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (usePhone == null) {
|
if (usePhone == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("InviteUser", R.string.InviteUser));
|
builder.setMessage(LocaleController.getString("InviteUser", R.string.InviteUser));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
final String arg1 = usePhone;
|
final String arg1 = usePhone;
|
||||||
@ -261,7 +300,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
try {
|
try {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", arg1, null));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", arg1, null));
|
||||||
intent.putExtra("sms_body", LocaleController.getString("InviteText", R.string.InviteText));
|
intent.putExtra("sms_body", LocaleController.getString("InviteText", R.string.InviteText));
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
@ -274,32 +313,11 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
emptyTextView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||||
Utilities.hideKeyboard(searchView);
|
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,10 +335,10 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void didSelectResult(final TLRPC.User user, boolean useAlert) {
|
private void didSelectResult(final TLRPC.User user, boolean useAlert) {
|
||||||
if (useAlert && selectAlertString != 0) {
|
if (useAlert && selectAlertString != null) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
|
||||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
@ -335,183 +353,19 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
delegate = null;
|
delegate = null;
|
||||||
}
|
}
|
||||||
finishFragment();
|
finishFragment();
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destroyAfterSelect) {
|
|
||||||
actionBar.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
|
|
||||||
} else {
|
|
||||||
actionBar.setTitle(LocaleController.getString("Contacts", R.string.Contacts));
|
|
||||||
}
|
|
||||||
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listViewAdapter != null) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listViewAdapter != null) {
|
|
||||||
listViewAdapter.notifyDataSetChanged();
|
listViewAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
actionBarLayer.closeSearchField();
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
|
|
||||||
searchItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, LocaleController.getString("Search", R.string.Search)).setIcon(R.drawable.ic_ab_search);
|
|
||||||
searchItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS|SupportMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
||||||
searchItem.setActionView(searchView = new SearchView(parentActivity));
|
|
||||||
|
|
||||||
TextView textView = (TextView) searchView.findViewById(R.id.search_src_text);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setTextColor(0xffffffff);
|
|
||||||
try {
|
|
||||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
|
||||||
mCursorDrawableRes.setAccessible(true);
|
|
||||||
mCursorDrawableRes.set(textView, R.drawable.search_carret);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
|
|
||||||
if (img != null) {
|
|
||||||
img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextSubmit(String s) {
|
|
||||||
Utilities.hideKeyboard(searchView);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextChange(String s) {
|
|
||||||
if (searchListViewAdapter == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (s.length() != 0) {
|
|
||||||
searchWas = true;
|
|
||||||
if (listView != null) {
|
|
||||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
searchListViewAdapter.searchDialogs(s);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchItem.setSupportOnActionExpandListener(new MenuItemCompat.OnActionExpandListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
|
||||||
if (parentActivity != null) {
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setIcon(R.drawable.ic_ab_search);
|
|
||||||
}
|
|
||||||
searching = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
searchView.setQuery("", false);
|
|
||||||
searchListViewAdapter.searchDialogs(null);
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
ViewGroup group = (ViewGroup) listView.getParent();
|
|
||||||
listView.setAdapter(listViewAdapter);
|
|
||||||
if (!LocaleController.isRTL) {
|
|
||||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
|
|
||||||
} else {
|
|
||||||
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
|
||||||
}
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
|
||||||
listView.setFastScrollAlwaysVisible(true);
|
|
||||||
}
|
|
||||||
listView.setFastScrollEnabled(true);
|
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
|
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -528,11 +382,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
} else if (id == MessagesController.encryptedChatCreated) {
|
} else if (id == MessagesController.encryptedChatCreated) {
|
||||||
if (createSecretChat && creatingChat) {
|
if (createSecretChat && creatingChat) {
|
||||||
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
|
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args2 = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args2.putInt("enc_id", encryptedChat.id);
|
||||||
bundle.putInt("enc_id", encryptedChat.id);
|
presentFragment(new ChatActivity(args2), true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -580,4 +432,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDelegate(ContactsActivityDelegate delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnoreUsers(HashMap<Integer, TLRPC.User> users) {
|
||||||
|
ignoreUsers = users;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,34 +9,29 @@
|
|||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
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.PinnedHeaderListView;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -44,9 +39,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class CountrySelectActivity extends ActionBarActivity {
|
public class CountrySelectActivity extends BaseFragment {
|
||||||
private SupportMenuItem searchItem;
|
|
||||||
private SearchView searchView;
|
public static interface CountrySelectActivityDelegate {
|
||||||
|
public abstract void didSelectCountry(String name);
|
||||||
|
}
|
||||||
|
|
||||||
private SectionedBaseAdapter listViewAdapter;
|
private SectionedBaseAdapter listViewAdapter;
|
||||||
private PinnedHeaderListView listView;
|
private PinnedHeaderListView listView;
|
||||||
private boolean searchWas;
|
private boolean searchWas;
|
||||||
@ -55,6 +53,7 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||||||
private TextView emptyTextView;
|
private TextView emptyTextView;
|
||||||
private HashMap<String, ArrayList<Country>> countries = new HashMap<String, ArrayList<Country>>();
|
private HashMap<String, ArrayList<Country>> countries = new HashMap<String, ArrayList<Country>>();
|
||||||
private ArrayList<String> sortedCountries = new ArrayList<String>();
|
private ArrayList<String> sortedCountries = new ArrayList<String>();
|
||||||
|
private CountrySelectActivityDelegate delegate;
|
||||||
|
|
||||||
private Timer searchTimer;
|
private Timer searchTimer;
|
||||||
public ArrayList<Country> searchResult;
|
public ArrayList<Country> searchResult;
|
||||||
@ -66,14 +65,10 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public boolean onFragmentCreate() {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt")));
|
InputStream stream = ApplicationLoader.applicationContext.getResources().getAssets().open("countries.txt");
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
String[] args = line.split(";");
|
String[] args = line.split(";");
|
||||||
@ -90,6 +85,8 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
arr.add(c);
|
arr.add(c);
|
||||||
}
|
}
|
||||||
|
reader.close();//TODO
|
||||||
|
stream.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
@ -110,218 +107,152 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setContentView(R.layout.country_select_layout);
|
return super.onFragmentCreate();
|
||||||
|
|
||||||
emptyTextView = (TextView)findViewById(R.id.searchEmptyView);
|
|
||||||
searchListViewAdapter = new SearchAdapter(this);
|
|
||||||
|
|
||||||
listView = (PinnedHeaderListView)findViewById(R.id.listView);
|
|
||||||
listView.setEmptyView(emptyTextView);
|
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
|
||||||
|
|
||||||
listView.setAdapter(listViewAdapter = new ListAdapter(this));
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
if (searching && searchWas) {
|
|
||||||
if (i < searchResult.size()) {
|
|
||||||
Country c = searchResult.get(i);
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra("country", c.name);
|
|
||||||
setResult(RESULT_OK, intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int section = listViewAdapter.getSectionForPosition(i);
|
|
||||||
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
|
||||||
if (section < sortedCountries.size()) {
|
|
||||||
String n = sortedCountries.get(section);
|
|
||||||
ArrayList<Country> arr = countries.get(n);
|
|
||||||
if (row < arr.size()) {
|
|
||||||
Country c = arr.get(row);
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra("country", c.name);
|
|
||||||
setResult(RESULT_OK, intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
|
||||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
|
||||||
Utilities.hideKeyboard(searchView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setTitle(getString(R.string.ChooseCountry));
|
|
||||||
fixBackButton();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onFragmentDestroy() {
|
||||||
super.onResume();
|
super.onFragmentDestroy();
|
||||||
applySelfActionBar();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||||
|
@Override
|
||||||
|
public void onSearchExpand() {
|
||||||
|
searching = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchCollapse() {
|
||||||
|
search(null);
|
||||||
|
searching = false;
|
||||||
|
searchWas = false;
|
||||||
|
ViewGroup group = (ViewGroup) listView.getParent();
|
||||||
|
listView.setAdapter(listViewAdapter);
|
||||||
|
if (!LocaleController.isRTL) {
|
||||||
|
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
|
||||||
|
} else {
|
||||||
|
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||||
|
}
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
|
listView.setFastScrollAlwaysVisible(true);
|
||||||
|
}
|
||||||
|
listView.setFastScrollEnabled(true);
|
||||||
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
|
||||||
|
emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(EditText editText) {
|
||||||
|
String text = editText.getText().toString();
|
||||||
|
search(text);
|
||||||
|
if (text.length() != 0) {
|
||||||
|
searchWas = true;
|
||||||
|
if (listView != null) {
|
||||||
|
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
searching = false;
|
||||||
|
searchWas = false;
|
||||||
|
|
||||||
|
fragmentView = inflater.inflate(R.layout.country_select_layout, container, false);
|
||||||
|
|
||||||
|
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
|
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
||||||
|
|
||||||
|
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
||||||
|
listView.setEmptyView(emptyTextView);
|
||||||
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
|
||||||
|
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
if (searching && searchWas) {
|
||||||
|
if (i < searchResult.size()) {
|
||||||
|
Country c = searchResult.get(i);
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.didSelectCountry(c.name);
|
||||||
|
}
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int section = listViewAdapter.getSectionForPosition(i);
|
||||||
|
int row = listViewAdapter.getPositionInSectionForPosition(i);
|
||||||
|
if (section < sortedCountries.size()) {
|
||||||
|
String n = sortedCountries.get(section);
|
||||||
|
ArrayList<Country> arr = countries.get(n);
|
||||||
|
if (row < arr.size()) {
|
||||||
|
Country c = arr.get(row);
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.didSelectCountry(c.name);
|
||||||
|
}
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||||
|
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||||
|
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(fragmentView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fragmentView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
if (listViewAdapter != null) {
|
||||||
|
listViewAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
actionBarLayer.closeSearchField();
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
searchItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, LocaleController.getString("Search", R.string.Search)).setIcon(R.drawable.ic_ab_search);
|
|
||||||
searchItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS|SupportMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
||||||
searchItem.setActionView(searchView = new SearchView(this));
|
|
||||||
|
|
||||||
TextView textView = (TextView) searchView.findViewById(R.id.search_src_text);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setTextColor(0xffffffff);
|
|
||||||
try {
|
|
||||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
|
||||||
mCursorDrawableRes.setAccessible(true);
|
|
||||||
mCursorDrawableRes.set(textView, R.drawable.search_carret);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
|
|
||||||
if (img != null) {
|
|
||||||
img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextSubmit(String s) {
|
|
||||||
Utilities.hideKeyboard(searchView);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextChange(String s) {
|
|
||||||
search(s);
|
|
||||||
if (s.length() != 0) {
|
|
||||||
searchWas = true;
|
|
||||||
if (listView != null) {
|
|
||||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.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(getString(R.string.NoResult));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchItem.setSupportOnActionExpandListener(new MenuItemCompat.OnActionExpandListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
|
||||||
getSupportActionBar().setIcon(R.drawable.ic_ab_search);
|
|
||||||
searching = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
|
||||||
searchView.setQuery("", false);
|
|
||||||
search(null);
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
ViewGroup group = (ViewGroup) listView.getParent();
|
|
||||||
listView.setAdapter(listViewAdapter);
|
|
||||||
if (!LocaleController.isRTL) {
|
|
||||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
|
|
||||||
} else {
|
|
||||||
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
|
||||||
}
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
|
||||||
listView.setFastScrollAlwaysVisible(true);
|
|
||||||
}
|
|
||||||
listView.setFastScrollEnabled(true);
|
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
|
||||||
applySelfActionBar();
|
|
||||||
|
|
||||||
emptyTextView.setText(getString(R.string.ChooseCountry));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fixBackButton() {
|
|
||||||
if(android.os.Build.VERSION.SDK_INT == 19) {
|
|
||||||
//workaround for back button dissapear
|
|
||||||
try {
|
|
||||||
Class firstClass = getSupportActionBar().getClass();
|
|
||||||
Class aClass = firstClass.getSuperclass();
|
|
||||||
if (aClass == android.support.v7.app.ActionBar.class) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Field field = aClass.getDeclaredField("mActionBar");
|
|
||||||
field.setAccessible(true);
|
|
||||||
android.app.ActionBar bar = (android.app.ActionBar)field.get(getSupportActionBar());
|
|
||||||
|
|
||||||
field = bar.getClass().getDeclaredField("mActionView");
|
|
||||||
field.setAccessible(true);
|
|
||||||
View v = (View)field.get(bar);
|
|
||||||
aClass = v.getClass();
|
|
||||||
|
|
||||||
field = aClass.getDeclaredField("mHomeLayout");
|
|
||||||
field.setAccessible(true);
|
|
||||||
v = (View)field.get(v);
|
|
||||||
v.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void search(final String query) {
|
public void search(final String query) {
|
||||||
@ -379,6 +310,10 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCountrySelectActivityDelegate(CountrySelectActivityDelegate delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSearchResults(final ArrayList<Country> arrCounties) {
|
private void updateSearchResults(final ArrayList<Country> arrCounties) {
|
||||||
Utilities.RunOnUIThread(new Runnable() {
|
Utilities.RunOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,12 +14,9 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -32,9 +29,9 @@ import org.telegram.messenger.FileLog;
|
|||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -58,7 +55,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
private boolean receiverRegistered = false;
|
private boolean receiverRegistered = false;
|
||||||
private ArrayList<HistoryEntry> history = new ArrayList<HistoryEntry>();
|
private ArrayList<HistoryEntry> history = new ArrayList<HistoryEntry>();
|
||||||
private long sizeLimit = 1024 * 1024 * 1024;
|
private long sizeLimit = 1024 * 1024 * 1024;
|
||||||
public DocumentSelectActivityDelegate delegate;
|
private DocumentSelectActivityDelegate delegate;
|
||||||
|
|
||||||
private class ListItem {
|
private class ListItem {
|
||||||
int icon;
|
int icon;
|
||||||
@ -99,17 +96,11 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onFragmentCreate() {
|
|
||||||
super.onFragmentCreate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public void onFragmentDestroy() {
|
||||||
try {
|
try {
|
||||||
if (receiverRegistered) {
|
if (receiverRegistered) {
|
||||||
parentActivity.unregisterReceiver(receiver);
|
getParentActivity().unregisterReceiver(receiver);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
@ -118,13 +109,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (!receiverRegistered) {
|
if (!receiverRegistered) {
|
||||||
receiverRegistered = true;
|
receiverRegistered = true;
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
@ -138,12 +123,23 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
|
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
|
||||||
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
|
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
|
||||||
filter.addDataScheme("file");
|
filter.addDataScheme("file");
|
||||||
parentActivity.registerReceiver(receiver, filter);
|
getParentActivity().registerReceiver(receiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.document_select_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.document_select_layout, container, false);
|
||||||
listAdapter = new ListAdapter(parentActivity);
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setEmptyView(emptyView);
|
listView.setEmptyView(emptyView);
|
||||||
@ -158,22 +154,21 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
he.scrollItem = listView.getFirstVisiblePosition();
|
he.scrollItem = listView.getFirstVisiblePosition();
|
||||||
he.scrollOffset = listView.getChildAt(0).getTop();
|
he.scrollOffset = listView.getChildAt(0).getTop();
|
||||||
he.dir = currentDir;
|
he.dir = currentDir;
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
he.title = actionBarLayer.getTitle().toString();
|
||||||
he.title = actionBar.getTitle().toString();
|
|
||||||
if (!listFiles(file)){
|
if (!listFiles(file)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
history.add(he);
|
history.add(he);
|
||||||
actionBar.setTitle(item.title);
|
actionBarLayer.setTitle(item.title);
|
||||||
listView.setSelection(0);
|
listView.setSelection(0);
|
||||||
} else {
|
} else {
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
showErrorBox(getString(R.string.AccessError));
|
showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sizeLimit != 0) {
|
if (sizeLimit != 0) {
|
||||||
if (file.length() > sizeLimit) {
|
if (file.length() > sizeLimit) {
|
||||||
showErrorBox(getString(R.string.FileUploadLimit, Utilities.formatFileSize(sizeLimit)));
|
showErrorBox(LocaleController.formatString("FileUploadLimit", R.string.FileUploadLimit, Utilities.formatFileSize(sizeLimit)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,11 +182,6 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
listRoots();
|
listRoots();
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
@ -202,66 +192,18 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listAdapter != null) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
if (history.size() > 0){
|
if (history.size() > 0){
|
||||||
HistoryEntry he = history.remove(history.size() - 1);
|
HistoryEntry he = history.remove(history.size() - 1);
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
actionBarLayer.setTitle(he.title);
|
||||||
actionBar.setTitle(he.title);
|
|
||||||
if (he.dir != null) {
|
if (he.dir != null) {
|
||||||
listFiles(he.dir);
|
listFiles(he.dir);
|
||||||
} else {
|
} else {
|
||||||
@ -273,6 +215,10 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
return super.onBackPressed();
|
return super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDelegate(DocumentSelectActivityDelegate delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean listFiles(File dir) {
|
private boolean listFiles(File dir) {
|
||||||
if (!dir.canRead()) {
|
if (!dir.canRead()) {
|
||||||
if (dir.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().toString())
|
if (dir.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().toString())
|
||||||
@ -292,7 +238,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showErrorBox(getString(R.string.AccessError));
|
showErrorBox(LocaleController.getString("AccessError", R.string.AccessError));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
emptyView.setText(LocaleController.getString("NoFiles", R.string.NoFiles));
|
emptyView.setText(LocaleController.getString("NoFiles", R.string.NoFiles));
|
||||||
@ -304,7 +250,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
showErrorBox(getString(R.string.UnknownError));
|
showErrorBox(LocaleController.getString("UnknownError", R.string.UnknownError));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
currentDir = dir;
|
currentDir = dir;
|
||||||
@ -344,7 +290,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorBox(String error){
|
private void showErrorBox(String error){
|
||||||
new AlertDialog.Builder(parentActivity)
|
new AlertDialog.Builder(getParentActivity())
|
||||||
.setTitle(LocaleController.getString("AppName", R.string.AppName))
|
.setTitle(LocaleController.getString("AppName", R.string.AppName))
|
||||||
.setMessage(error)
|
.setMessage(error)
|
||||||
.setPositiveButton(R.string.OK, null)
|
.setPositiveButton(R.string.OK, null)
|
||||||
@ -356,7 +302,11 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
items.clear();
|
items.clear();
|
||||||
String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
|
String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
ListItem ext = new ListItem();
|
ListItem ext = new ListItem();
|
||||||
ext.title = getString(Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable() ? R.string.SdCard : R.string.InternalStorage);
|
if (Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable()) {
|
||||||
|
ext.title = LocaleController.getString("SdCard", R.string.SdCard);
|
||||||
|
} else {
|
||||||
|
ext.title = LocaleController.getString("InternalStorage", R.string.InternalStorage);
|
||||||
|
}
|
||||||
ext.icon = Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable() ? R.drawable.ic_external_storage : R.drawable.ic_storage;
|
ext.icon = Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable() ? R.drawable.ic_external_storage : R.drawable.ic_storage;
|
||||||
ext.subtitle = getRootSubtitle(extStorage);
|
ext.subtitle = getRootSubtitle(extStorage);
|
||||||
ext.file = Environment.getExternalStorageDirectory();
|
ext.file = Environment.getExternalStorageDirectory();
|
||||||
@ -386,9 +336,12 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||||||
result.removeAll(aliases.get(extDevice));
|
result.removeAll(aliases.get(extDevice));
|
||||||
for (String path : result) {
|
for (String path : result) {
|
||||||
try {
|
try {
|
||||||
boolean isSd = path.toLowerCase().contains("sd");
|
|
||||||
ListItem item = new ListItem();
|
ListItem item = new ListItem();
|
||||||
item.title = getString(isSd ? R.string.SdCard : R.string.ExternalStorage);
|
if (path.toLowerCase().contains("sd")) {
|
||||||
|
ext.title = LocaleController.getString("SdCard", R.string.SdCard);
|
||||||
|
} else {
|
||||||
|
ext.title = LocaleController.getString("ExternalStorage", R.string.ExternalStorage);
|
||||||
|
}
|
||||||
item.icon = R.drawable.ic_external_storage;
|
item.icon = R.drawable.ic_external_storage;
|
||||||
item.subtitle = getRootSubtitle(path);
|
item.subtitle = getRootSubtitle(path);
|
||||||
item.file = new File(path);
|
item.file = new File(path);
|
||||||
|
@ -17,8 +17,6 @@ import android.graphics.drawable.BitmapDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
@ -26,9 +24,6 @@ import android.text.SpannableStringBuilder;
|
|||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.style.ImageSpan;
|
import android.text.style.ImageSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
@ -48,8 +43,10 @@ import org.telegram.messenger.NotificationCenter;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
import org.telegram.ui.Views.PinnedHeaderListView;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||||
|
|
||||||
@ -105,17 +102,14 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
private CharSequence changeString;
|
private CharSequence changeString;
|
||||||
private int beforeChangeIndex;
|
private int beforeChangeIndex;
|
||||||
|
|
||||||
public GroupCreateActivity() {
|
private final static int done_button = 1;
|
||||||
animationType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.chatDidCreated);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.chatDidCreated);
|
||||||
return true;
|
return super.onFragmentCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,14 +121,33 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
|
||||||
|
actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
} else if (id == done_button) {
|
||||||
|
if (!selectedContacts.isEmpty()) {
|
||||||
|
ArrayList<Integer> result = new ArrayList<Integer>();
|
||||||
|
result.addAll(selectedContacts.keySet());
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putIntegerArrayList("result", result);
|
||||||
|
presentFragment(new GroupCreateFinalActivity(args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout);
|
||||||
|
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
|
||||||
|
doneTextView.setText(LocaleController.getString("Next", R.string.Next));
|
||||||
|
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
@ -186,10 +199,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
selectedContacts.remove(sp.uid);
|
selectedContacts.remove(sp.uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (parentActivity != null) {
|
actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));
|
|
||||||
}
|
|
||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
} else {
|
} else {
|
||||||
search = true;
|
search = true;
|
||||||
@ -222,7 +232,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
listView.setEmptyView(emptyTextView);
|
listView.setEmptyView(emptyTextView);
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
|
||||||
listView.setAdapter(listViewAdapter = new ListAdapter(parentActivity));
|
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
@ -255,10 +265,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
span.uid = user.id;
|
span.uid = user.id;
|
||||||
ignoreChange = false;
|
ignoreChange = false;
|
||||||
}
|
}
|
||||||
if (parentActivity != null) {
|
actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));
|
|
||||||
}
|
|
||||||
if (searching || searchWas) {
|
if (searching || searchWas) {
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
@ -302,44 +309,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
|
|
||||||
actionBar.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public XImageSpan createAndPutChipForUser(TLRPC.User user) {
|
public XImageSpan createAndPutChipForUser(TLRPC.User user) {
|
||||||
LayoutInflater lf = (LayoutInflater)parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater lf = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
||||||
View textView = lf.inflate(R.layout.group_create_bubble, null);
|
View textView = lf.inflate(R.layout.group_create_bubble, null);
|
||||||
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
|
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
|
||||||
String name = Utilities.formatName(user.first_name, user.last_name);
|
String name = Utilities.formatName(user.first_name, user.last_name);
|
||||||
@ -451,41 +422,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
SupportMenuItem doneItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, null);
|
|
||||||
doneItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
doneItem.setActionView(R.layout.group_create_done_layout);
|
|
||||||
|
|
||||||
TextView doneTextView = (TextView)doneItem.getActionView().findViewById(R.id.done_button);
|
|
||||||
doneTextView.setText(LocaleController.getString("Next", R.string.Next));
|
|
||||||
doneTextView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (!selectedContacts.isEmpty()) {
|
|
||||||
ArrayList<Integer> result = new ArrayList<Integer>();
|
|
||||||
result.addAll(selectedContacts.keySet());
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putIntegerArrayList("result", result);
|
|
||||||
GroupCreateFinalActivity fragment = new GroupCreateFinalActivity();
|
|
||||||
fragment.setArguments(args);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "group_craate_final", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didReceivedNotification(int id, Object... args) {
|
public void didReceivedNotification(int id, Object... args) {
|
||||||
if (id == MessagesController.contactsDidLoaded) {
|
if (id == MessagesController.contactsDidLoaded) {
|
||||||
|
@ -14,12 +14,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -36,9 +31,11 @@ import org.telegram.messenger.NotificationCenter;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
import org.telegram.ui.Views.AvatarUpdater;
|
import org.telegram.ui.Views.AvatarUpdater;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
import org.telegram.ui.Views.PinnedHeaderListView;
|
||||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||||
|
|
||||||
@ -58,10 +55,15 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
private ProgressDialog progressDialog = null;
|
private ProgressDialog progressDialog = null;
|
||||||
private String nameToSet = null;
|
private String nameToSet = null;
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
|
public GroupCreateFinalActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.chatDidCreated);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.chatDidCreated);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.chatDidFailCreate);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.chatDidFailCreate);
|
||||||
@ -101,7 +103,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return super.onFragmentCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,14 +116,59 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
} else if (id == done_button) {
|
||||||
|
if (donePressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nameTextView.getText().length() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
donePressed = true;
|
||||||
|
|
||||||
|
if (avatarUpdater.uploadingAvatar != null) {
|
||||||
|
createAfterUpload = true;
|
||||||
|
} else {
|
||||||
|
progressDialog = new ProgressDialog(getParentActivity());
|
||||||
|
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
||||||
|
progressDialog.setCanceledOnTouchOutside(false);
|
||||||
|
progressDialog.setCancelable(false);
|
||||||
|
|
||||||
|
final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar);
|
||||||
|
|
||||||
|
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
ConnectionsManager.getInstance().cancelRpc(reqId, true);
|
||||||
|
donePressed = false;
|
||||||
|
try {
|
||||||
|
dialog.dismiss();
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
progressDialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout);
|
||||||
|
|
||||||
|
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
|
||||||
|
doneTextView.setText(LocaleController.getString("Done", R.string.Done));
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false);
|
||||||
|
|
||||||
final ImageButton button2 = (ImageButton)fragmentView.findViewById(R.id.settings_change_avatar_button);
|
final ImageButton button2 = (ImageButton)fragmentView.findViewById(R.id.settings_change_avatar_button);
|
||||||
@ -129,7 +176,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
|
||||||
CharSequence[] items;
|
CharSequence[] items;
|
||||||
|
|
||||||
@ -166,7 +213,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
nameToSet = null;
|
nameToSet = null;
|
||||||
}
|
}
|
||||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setAdapter(new ListAdapter(parentActivity));
|
listView.setAdapter(new ListAdapter(getParentActivity()));
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -176,42 +223,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big) {
|
public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big) {
|
||||||
Utilities.RunOnUIThread(new Runnable() {
|
Utilities.RunOnUIThread(new Runnable() {
|
||||||
@ -228,17 +239,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||||
avatarUpdater.onActivityResult(requestCode, resultCode, data);
|
avatarUpdater.onActivityResult(requestCode, resultCode, data);
|
||||||
@ -272,53 +272,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
SupportMenuItem doneItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, null);
|
|
||||||
doneItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
doneItem.setActionView(R.layout.group_create_done_layout);
|
|
||||||
|
|
||||||
TextView doneTextView = (TextView)doneItem.getActionView().findViewById(R.id.done_button);
|
|
||||||
doneTextView.setText(LocaleController.getString("Done", R.string.Done));
|
|
||||||
doneTextView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (donePressed || parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (nameTextView.getText().length() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
donePressed = true;
|
|
||||||
|
|
||||||
if (avatarUpdater.uploadingAvatar != null) {
|
|
||||||
createAfterUpload = true;
|
|
||||||
} else {
|
|
||||||
progressDialog = new ProgressDialog(parentActivity);
|
|
||||||
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
|
||||||
progressDialog.setCanceledOnTouchOutside(false);
|
|
||||||
progressDialog.setCancelable(false);
|
|
||||||
|
|
||||||
final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar);
|
|
||||||
|
|
||||||
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
ConnectionsManager.getInstance().cancelRpc(reqId, true);
|
|
||||||
donePressed = false;
|
|
||||||
try {
|
|
||||||
dialog.dismiss();
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
progressDialog.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didReceivedNotification(int id, final Object... args) {
|
public void didReceivedNotification(int id, final Object... args) {
|
||||||
if (id == MessagesController.updateInterfaces) {
|
if (id == MessagesController.updateInterfaces) {
|
||||||
@ -335,7 +288,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
donePressed = false;
|
donePressed = false;
|
||||||
FileLog.e("tmessages", "did fail create chat");
|
|
||||||
} else if (id == MessagesController.chatDidCreated) {
|
} else if (id == MessagesController.chatDidCreated) {
|
||||||
Utilities.RunOnUIThread(new Runnable() {
|
Utilities.RunOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -347,11 +299,9 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args2 = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args2.putInt("chat_id", (Integer)args[0]);
|
||||||
bundle.putInt("chat_id", (Integer)args[0]);
|
presentFragment(new ChatActivity(args2));
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,8 @@ package org.telegram.ui;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -27,12 +25,17 @@ import org.telegram.messenger.TLRPC;
|
|||||||
import org.telegram.messenger.MessagesController;
|
import org.telegram.messenger.MessagesController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.IdenticonView;
|
import org.telegram.ui.Views.IdenticonView;
|
||||||
|
|
||||||
public class IdenticonActivity extends BaseFragment {
|
public class IdenticonActivity extends BaseFragment {
|
||||||
private int chat_id;
|
private int chat_id;
|
||||||
|
|
||||||
|
public IdenticonActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
chat_id = getArguments().getInt("chat_id");
|
chat_id = getArguments().getInt("chat_id");
|
||||||
@ -40,19 +43,21 @@ public class IdenticonActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onFragmentDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
||||||
|
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
|
||||||
IdenticonView identiconView = (IdenticonView) fragmentView.findViewById(R.id.identicon_view);
|
IdenticonView identiconView = (IdenticonView) fragmentView.findViewById(R.id.identicon_view);
|
||||||
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
|
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
|
||||||
@ -71,32 +76,6 @@ public class IdenticonActivity extends BaseFragment {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(Utilities.dp(4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
@ -105,62 +84,29 @@ public class IdenticonActivity extends BaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
fixLayout();
|
fixLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixLayout() {
|
private void fixLayout() {
|
||||||
final View v = getView();
|
ViewTreeObserver obs = fragmentView.getViewTreeObserver();
|
||||||
if (v != null) {
|
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||||
ViewTreeObserver obs = v.getViewTreeObserver();
|
@Override
|
||||||
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
public boolean onPreDraw() {
|
||||||
@Override
|
LinearLayout layout = (LinearLayout)fragmentView;
|
||||||
public boolean onPreDraw() {
|
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
||||||
LinearLayout layout = (LinearLayout)fragmentView;
|
int rotation = manager.getDefaultDisplay().getRotation();
|
||||||
WindowManager manager = (WindowManager)parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
int rotation = manager.getDefaultDisplay().getRotation();
|
|
||||||
|
|
||||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||||
layout.setOrientation(LinearLayout.HORIZONTAL);
|
layout.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
} else {
|
} else {
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
}
|
|
||||||
|
|
||||||
v.setPadding(v.getPaddingLeft(), 0, v.getPaddingRight(), v.getPaddingBottom());
|
|
||||||
v.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = ApplicationLoader.applicationContext.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(Utilities.dp(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(), fragmentView.getPaddingBottom());
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
return false;
|
||||||
case android.R.id.home:
|
}
|
||||||
finishFragment();
|
});
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,8 @@ public class IntroActivity extends ActionBarActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
startPressed = true;
|
startPressed = true;
|
||||||
Intent intent2 = new Intent(IntroActivity.this, LoginActivity.class);
|
Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
|
||||||
|
intent2.putExtra("fromIntro", true);
|
||||||
startActivity(intent2);
|
startActivity(intent2);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -11,21 +11,13 @@ package org.telegram.ui;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -33,17 +25,16 @@ import org.telegram.messenger.FileLog;
|
|||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class LanguageSelectActivity extends BaseFragment {
|
public class LanguageSelectActivity extends BaseFragment {
|
||||||
private SupportMenuItem searchItem;
|
|
||||||
private SearchView searchView;
|
|
||||||
private BaseAdapter listAdapter;
|
private BaseAdapter listAdapter;
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private boolean searchWas;
|
private boolean searchWas;
|
||||||
@ -55,39 +46,71 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
public ArrayList<LocaleController.LocaleInfo> searchResult;
|
public ArrayList<LocaleController.LocaleInfo> searchResult;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onFragmentCreate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFragmentDestroy() {
|
|
||||||
super.onFragmentDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("Language", R.string.Language));
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||||
|
@Override
|
||||||
|
public void onSearchExpand() {
|
||||||
|
searching = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchCollapse() {
|
||||||
|
search(null);
|
||||||
|
searching = false;
|
||||||
|
searchWas = false;
|
||||||
|
if (listView != null) {
|
||||||
|
emptyTextView.setVisibility(View.GONE);
|
||||||
|
listView.setAdapter(listAdapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(EditText editText) {
|
||||||
|
String text = editText.getText().toString();
|
||||||
|
search(text);
|
||||||
|
if (text.length() != 0) {
|
||||||
|
searchWas = true;
|
||||||
|
if (listView != null) {
|
||||||
|
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.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);
|
fragmentView = inflater.inflate(R.layout.language_select_layout, container, false);
|
||||||
listAdapter = new ListAdapter(parentActivity);
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
listView.setEmptyView(emptyTextView);
|
listView.setEmptyView(emptyTextView);
|
||||||
searchListViewAdapter = new SearchAdapter(parentActivity);
|
searchListViewAdapter = new SearchAdapter(getParentActivity());
|
||||||
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LocaleController.LocaleInfo localeInfo = null;
|
LocaleController.LocaleInfo localeInfo = null;
|
||||||
if (searching && searchWas) {
|
if (searching && searchWas) {
|
||||||
if (i >= 0 && i < searchResult.size()) {
|
if (i >= 0 && i < searchResult.size()) {
|
||||||
@ -99,26 +122,8 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (localeInfo != null) {
|
if (localeInfo != null) {
|
||||||
boolean isRTL = LocaleController.isRTL;
|
|
||||||
LocaleController.getInstance().applyLanguage(localeInfo, true);
|
LocaleController.getInstance().applyLanguage(localeInfo, true);
|
||||||
if (isRTL != LocaleController.isRTL) {
|
getParentActivity().rebuildAllFragmentViews();
|
||||||
for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
|
|
||||||
if (fragment == LanguageSelectActivity.this) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (fragment.fragmentView != null) {
|
|
||||||
ViewGroup parent = (ViewGroup)fragment.fragmentView.getParent();
|
|
||||||
if (parent != null) {
|
|
||||||
parent.removeView(fragment.fragmentView);
|
|
||||||
}
|
|
||||||
fragment.fragmentView = null;
|
|
||||||
}
|
|
||||||
fragment.parentActivity = parentActivity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
}
|
||||||
finishFragment();
|
finishFragment();
|
||||||
}
|
}
|
||||||
@ -127,9 +132,6 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LocaleController.LocaleInfo localeInfo = null;
|
LocaleController.LocaleInfo localeInfo = null;
|
||||||
if (searching && searchWas) {
|
if (searching && searchWas) {
|
||||||
if (i >= 0 && i < searchResult.size()) {
|
if (i >= 0 && i < searchResult.size()) {
|
||||||
@ -144,7 +146,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
|
final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization));
|
builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() {
|
||||||
@ -160,10 +162,6 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
if (searchListViewAdapter != null) {
|
if (searchListViewAdapter != null) {
|
||||||
searchListViewAdapter.notifyDataSetChanged();
|
searchListViewAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
applySelfActionBar();
|
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -173,17 +171,11 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||||
Utilities.hideKeyboard(searchView);
|
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,150 +195,16 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
actionBar.setTitle(LocaleController.getString("Language", R.string.Language));
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listAdapter != null) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
actionBarLayer.closeSearchField();
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
searchItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, LocaleController.getString("Search", R.string.Search)).setIcon(R.drawable.ic_ab_search);
|
|
||||||
searchItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS|SupportMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
||||||
searchItem.setActionView(searchView = new SearchView(parentActivity));
|
|
||||||
|
|
||||||
TextView textView = (TextView) searchView.findViewById(R.id.search_src_text);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setTextColor(0xffffffff);
|
|
||||||
try {
|
|
||||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
|
||||||
mCursorDrawableRes.setAccessible(true);
|
|
||||||
mCursorDrawableRes.set(textView, R.drawable.search_carret);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
|
|
||||||
if (img != null) {
|
|
||||||
img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextSubmit(String s) {
|
|
||||||
Utilities.hideKeyboard(searchView);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextChange(String s) {
|
|
||||||
search(s);
|
|
||||||
if (s.length() != 0) {
|
|
||||||
searchWas = true;
|
|
||||||
if (listView != null) {
|
|
||||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.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(getString(R.string.NoResult));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchItem.setSupportOnActionExpandListener(new MenuItemCompat.OnActionExpandListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
|
||||||
if (parentActivity != null) {
|
|
||||||
parentActivity.getSupportActionBar().setIcon(R.drawable.ic_ab_search);
|
|
||||||
}
|
|
||||||
searching = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
|
||||||
searchView.setQuery("", false);
|
|
||||||
search(null);
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
if (listView != null) {
|
|
||||||
emptyTextView.setVisibility(View.GONE);
|
|
||||||
listView.setAdapter(listAdapter);
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void search(final String query) {
|
public void search(final String query) {
|
||||||
|
@ -8,26 +8,19 @@
|
|||||||
|
|
||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -36,6 +29,7 @@ import android.widget.Toast;
|
|||||||
import org.telegram.PhoneFormat.PhoneFormat;
|
import org.telegram.PhoneFormat.PhoneFormat;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.MediaController;
|
import org.telegram.messenger.MediaController;
|
||||||
import org.telegram.messenger.MessagesController;
|
import org.telegram.messenger.MessagesController;
|
||||||
import org.telegram.messenger.NotificationCenter;
|
import org.telegram.messenger.NotificationCenter;
|
||||||
@ -44,14 +38,13 @@ import org.telegram.messenger.TLRPC;
|
|||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.objects.MessageObject;
|
import org.telegram.objects.MessageObject;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarActivity;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.NotificationView;
|
import org.telegram.ui.Views.NotificationView;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -70,35 +63,33 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
private View backStatusButton;
|
private View backStatusButton;
|
||||||
private View statusBackground;
|
private View statusBackground;
|
||||||
private TextView statusText;
|
private TextView statusText;
|
||||||
private View containerView;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
ApplicationLoader.postInitApplication();
|
ApplicationLoader.postInitApplication();
|
||||||
|
|
||||||
this.setTheme(R.style.Theme_TMessages);
|
|
||||||
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
|
||||||
|
|
||||||
if (!UserConfig.clientActivated) {
|
if (!UserConfig.clientActivated) {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
|
if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
|
||||||
|
super.onCreateFinish(savedInstanceState);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", MODE_PRIVATE);
|
if (intent != null && !intent.getBooleanExtra("fromIntro", false)) {
|
||||||
Map<String, ?> state = preferences.getAll();
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", MODE_PRIVATE);
|
||||||
if (state.isEmpty()) {
|
Map<String, ?> state = preferences.getAll();
|
||||||
Intent intent2 = new Intent(this, IntroActivity.class);
|
if (state.isEmpty()) {
|
||||||
startActivity(intent2);
|
Intent intent2 = new Intent(this, IntroActivity.class);
|
||||||
} else {
|
startActivity(intent2);
|
||||||
Intent intent2 = new Intent(this, LoginActivity.class);
|
super.onCreateFinish(savedInstanceState);
|
||||||
startActivity(intent2);
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||||
if (resourceId > 0) {
|
if (resourceId > 0) {
|
||||||
Utilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
Utilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
||||||
@ -106,43 +97,37 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
|
|
||||||
NotificationCenter.getInstance().postNotificationName(702, this);
|
NotificationCenter.getInstance().postNotificationName(702, this);
|
||||||
currentConnectionState = ConnectionsManager.getInstance().connectionState;
|
currentConnectionState = ConnectionsManager.getInstance().connectionState;
|
||||||
for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
|
|
||||||
if (fragment.fragmentView != null) {
|
|
||||||
ViewGroup parent = (ViewGroup)fragment.fragmentView.getParent();
|
|
||||||
if (parent != null) {
|
|
||||||
parent.removeView(fragment.fragmentView);
|
|
||||||
}
|
|
||||||
fragment.fragmentView = null;
|
|
||||||
}
|
|
||||||
fragment.parentActivity = this;
|
|
||||||
}
|
|
||||||
setContentView(R.layout.application_layout);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, 1234);
|
NotificationCenter.getInstance().addObserver(this, 1234);
|
||||||
NotificationCenter.getInstance().addObserver(this, 658);
|
NotificationCenter.getInstance().addObserver(this, 658);
|
||||||
NotificationCenter.getInstance().addObserver(this, 701);
|
NotificationCenter.getInstance().addObserver(this, 701);
|
||||||
NotificationCenter.getInstance().addObserver(this, 702);
|
NotificationCenter.getInstance().addObserver(this, 702);
|
||||||
NotificationCenter.getInstance().addObserver(this, 703);
|
NotificationCenter.getInstance().addObserver(this, 703);
|
||||||
NotificationCenter.getInstance().addObserver(this, GalleryImageViewer.needShowAllMedia);
|
NotificationCenter.getInstance().addObserver(this, GalleryImageViewer.needShowAllMedia);
|
||||||
getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2);
|
|
||||||
|
|
||||||
statusView = getLayoutInflater().inflate(R.layout.updating_state_layout, null);
|
statusView = getLayoutInflater().inflate(R.layout.updating_state_layout, null);
|
||||||
statusBackground = statusView.findViewById(R.id.back_button_background);
|
statusBackground = statusView.findViewById(R.id.back_button_background);
|
||||||
backStatusButton = statusView.findViewById(R.id.back_button);
|
backStatusButton = statusView.findViewById(R.id.back_button);
|
||||||
containerView = findViewById(R.id.container);
|
|
||||||
statusText = (TextView)statusView.findViewById(R.id.status_text);
|
statusText = (TextView)statusView.findViewById(R.id.status_text);
|
||||||
statusBackground.setOnClickListener(new View.OnClickListener() {
|
statusBackground.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (ApplicationLoader.fragmentsStack.size() > 1) {
|
if (fragmentsStack.size() > 1) {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ApplicationLoader.fragmentsStack.isEmpty()) {
|
if (fragmentsStack.isEmpty()) {
|
||||||
MessagesActivity fragment = new MessagesActivity();
|
if (!UserConfig.clientActivated) {
|
||||||
fragment.onFragmentCreate();
|
LoginActivity fragment = new LoginActivity();
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
fragment.onFragmentCreate();
|
||||||
|
fragmentsStack.add(fragment);
|
||||||
|
} else {
|
||||||
|
MessagesActivity fragment = new MessagesActivity(null);
|
||||||
|
fragment.onFragmentCreate();
|
||||||
|
fragmentsStack.add(fragment);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
@ -151,10 +136,9 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
Bundle args = savedInstanceState.getBundle("args");
|
Bundle args = savedInstanceState.getBundle("args");
|
||||||
if (fragmentName.equals("chat")) {
|
if (fragmentName.equals("chat")) {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
ChatActivity chat = new ChatActivity();
|
ChatActivity chat = new ChatActivity(args);
|
||||||
chat.setArguments(args);
|
|
||||||
if (chat.onFragmentCreate()) {
|
if (chat.onFragmentCreate()) {
|
||||||
ApplicationLoader.fragmentsStack.add(chat);
|
fragmentsStack.add(chat);
|
||||||
chat.restoreSelfArgs(savedInstanceState);
|
chat.restoreSelfArgs(savedInstanceState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,21 +146,28 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
SettingsActivity settings = new SettingsActivity();
|
SettingsActivity settings = new SettingsActivity();
|
||||||
settings.onFragmentCreate();
|
settings.onFragmentCreate();
|
||||||
settings.restoreSelfArgs(savedInstanceState);
|
settings.restoreSelfArgs(savedInstanceState);
|
||||||
ApplicationLoader.fragmentsStack.add(settings);
|
fragmentsStack.add(settings);
|
||||||
} else if (fragmentName.equals("group")) {
|
} else if (fragmentName.equals("group")) {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
GroupCreateFinalActivity group = new GroupCreateFinalActivity();
|
GroupCreateFinalActivity group = new GroupCreateFinalActivity(args);
|
||||||
group.setArguments(args);
|
|
||||||
if (group.onFragmentCreate()) {
|
if (group.onFragmentCreate()) {
|
||||||
group.restoreSelfArgs(savedInstanceState);
|
group.restoreSelfArgs(savedInstanceState);
|
||||||
ApplicationLoader.fragmentsStack.add(group);
|
fragmentsStack.add(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (fragmentName.equals("chat_profile")) {
|
||||||
|
if (args != null) {
|
||||||
|
ChatProfileActivity profile = new ChatProfileActivity(args);
|
||||||
|
if (profile.onFragmentCreate()) {
|
||||||
|
profile.restoreSelfArgs(savedInstanceState);
|
||||||
|
fragmentsStack.add(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fragmentName.equals("wallpapers")) {
|
} else if (fragmentName.equals("wallpapers")) {
|
||||||
SettingsWallpapersActivity settings = new SettingsWallpapersActivity();
|
SettingsWallpapersActivity settings = new SettingsWallpapersActivity();
|
||||||
settings.onFragmentCreate();
|
settings.onFragmentCreate();
|
||||||
settings.restoreSelfArgs(savedInstanceState);
|
settings.restoreSelfArgs(savedInstanceState);
|
||||||
ApplicationLoader.fragmentsStack.add(settings);
|
fragmentsStack.add(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,35 +179,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
handleIntent(getIntent(), false, savedInstanceState != null);
|
handleIntent(getIntent(), false, savedInstanceState != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void prepareForHideShowActionBar() {
|
|
||||||
try {
|
|
||||||
Class firstClass = getSupportActionBar().getClass();
|
|
||||||
Class aClass = firstClass.getSuperclass();
|
|
||||||
if (aClass == android.support.v7.app.ActionBar.class) {
|
|
||||||
Method method = firstClass.getDeclaredMethod("setShowHideAnimationEnabled", boolean.class);
|
|
||||||
method.invoke(getSupportActionBar(), false);
|
|
||||||
} else {
|
|
||||||
Field field = aClass.getDeclaredField("mActionBar");
|
|
||||||
field.setAccessible(true);
|
|
||||||
Method method = field.get(getSupportActionBar()).getClass().getDeclaredMethod("setShowHideAnimationEnabled", boolean.class);
|
|
||||||
method.invoke(field.get(getSupportActionBar()), false);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showActionBar() {
|
|
||||||
prepareForHideShowActionBar();
|
|
||||||
getSupportActionBar().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideActionBar() {
|
|
||||||
prepareForHideShowActionBar();
|
|
||||||
getSupportActionBar().hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleIntent(Intent intent, boolean isNew, boolean restore) {
|
private void handleIntent(Intent intent, boolean isNew, boolean restore) {
|
||||||
boolean pushOpened = false;
|
boolean pushOpened = false;
|
||||||
|
|
||||||
@ -483,61 +445,44 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
if (push_user_id == UserConfig.clientUserId) {
|
if (push_user_id == UserConfig.clientUserId) {
|
||||||
open_settings = 1;
|
open_settings = 1;
|
||||||
} else {
|
} else {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("user_id", push_user_id);
|
||||||
bundle.putInt("user_id", push_user_id);
|
ChatActivity fragment = new ChatActivity(args);
|
||||||
fragment.setArguments(bundle);
|
if (presentFragment(fragment, false, true)) {
|
||||||
if (fragment.onFragmentCreate()) {
|
|
||||||
pushOpened = true;
|
pushOpened = true;
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (push_chat_id != 0) {
|
} else if (push_chat_id != 0) {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("chat_id", push_chat_id);
|
||||||
bundle.putInt("chat_id", push_chat_id);
|
ChatActivity fragment = new ChatActivity(args);
|
||||||
fragment.setArguments(bundle);
|
if (presentFragment(fragment, false, true)) {
|
||||||
if (fragment.onFragmentCreate()) {
|
|
||||||
pushOpened = true;
|
pushOpened = true;
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
|
|
||||||
}
|
}
|
||||||
} else if (push_enc_id != 0) {
|
} else if (push_enc_id != 0) {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("enc_id", push_enc_id);
|
||||||
bundle.putInt("enc_id", push_enc_id);
|
ChatActivity fragment = new ChatActivity(args);
|
||||||
fragment.setArguments(bundle);
|
if (presentFragment(fragment, false, true)) {
|
||||||
if (fragment.onFragmentCreate()) {
|
|
||||||
pushOpened = true;
|
pushOpened = true;
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (videoPath != null || photoPath != null || sendingText != null || documentPath != null || documentsPathArray != null || imagesPathArray != null || contactsToSend != null) {
|
if (videoPath != null || photoPath != null || sendingText != null || documentPath != null || documentsPathArray != null || imagesPathArray != null || contactsToSend != null) {
|
||||||
MessagesActivity fragment = new MessagesActivity();
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
fragment.selectAlertString = R.string.ForwardMessagesTo;
|
|
||||||
fragment.selectAlertStringDesc = "ForwardMessagesTo";
|
|
||||||
fragment.animationType = 1;
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlySelect", true);
|
args.putBoolean("onlySelect", true);
|
||||||
fragment.setArguments(args);
|
args.putString("selectAlertString", LocaleController.getString("ForwardMessagesTo", R.string.ForwardMessagesTo));
|
||||||
fragment.delegate = this;
|
MessagesActivity fragment = new MessagesActivity(args);
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
fragment.setDelegate(this);
|
||||||
fragment.onFragmentCreate();
|
presentFragment(fragment, false, true);
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag()).commitAllowingStateLoss();
|
|
||||||
pushOpened = true;
|
pushOpened = true;
|
||||||
}
|
}
|
||||||
if (open_settings != 0) {
|
if (open_settings != 0) {
|
||||||
SettingsActivity fragment = new SettingsActivity();
|
presentFragment(new SettingsActivity(), false, true);
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
fragment.onFragmentCreate();
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "settings").commitAllowingStateLoss();
|
|
||||||
pushOpened = true;
|
pushOpened = true;
|
||||||
}
|
}
|
||||||
if (!pushOpened && !isNew) {
|
if (!pushOpened && !isNew) {
|
||||||
BaseFragment fragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
showLastFragment();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag()).commitAllowingStateLoss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getIntent().setAction(null);
|
getIntent().setAction(null);
|
||||||
@ -554,30 +499,20 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
if (dialog_id != 0) {
|
if (dialog_id != 0) {
|
||||||
int lower_part = (int)dialog_id;
|
int lower_part = (int)dialog_id;
|
||||||
|
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putBoolean("scrollToTopOnResume", true);
|
||||||
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
if (lower_part != 0) {
|
if (lower_part != 0) {
|
||||||
if (lower_part > 0) {
|
if (lower_part > 0) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
args.putInt("user_id", lower_part);
|
||||||
bundle.putInt("user_id", lower_part);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
fragment.scrollToTopOnResume = true;
|
|
||||||
presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
} else if (lower_part < 0) {
|
} else if (lower_part < 0) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
args.putInt("chat_id", -lower_part);
|
||||||
bundle.putInt("chat_id", -lower_part);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
fragment.scrollToTopOnResume = true;
|
|
||||||
presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
args.putInt("enc_id", (int)(dialog_id >> 32));
|
||||||
int chat_id = (int)(dialog_id >> 32);
|
|
||||||
bundle.putInt("enc_id", chat_id);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
fragment.scrollToTopOnResume = true;
|
|
||||||
presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
}
|
}
|
||||||
|
ChatActivity fragment = new ChatActivity(args);
|
||||||
|
presentFragment(fragment, true);
|
||||||
if (photoPath != null) {
|
if (photoPath != null) {
|
||||||
fragment.processSendingPhoto(null, photoPath);
|
fragment.processSendingPhoto(null, photoPath);
|
||||||
}
|
}
|
||||||
@ -618,8 +553,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (ApplicationLoader.fragmentsStack.size() != 0) {
|
if (fragmentsStack.size() != 0) {
|
||||||
BaseFragment fragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
BaseFragment fragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,7 +575,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
processOnFinish();
|
onFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -649,11 +584,9 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
if (notificationView == null && getLayoutInflater() != null) {
|
if (notificationView == null && getLayoutInflater() != null) {
|
||||||
notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null);
|
notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null);
|
||||||
}
|
}
|
||||||
fixLayout();
|
|
||||||
Utilities.checkForCrashes(this);
|
Utilities.checkForCrashes(this);
|
||||||
Utilities.checkForUpdates(this);
|
Utilities.checkForUpdates(this);
|
||||||
ApplicationLoader.resetLastPauseTime();
|
ApplicationLoader.resetLastPauseTime();
|
||||||
supportInvalidateOptionsMenu();
|
|
||||||
updateActionBar();
|
updateActionBar();
|
||||||
try {
|
try {
|
||||||
NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
@ -664,7 +597,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processOnFinish() {
|
@Override
|
||||||
|
protected void onFinish() {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -686,40 +620,20 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
Utilities.checkDisplaySize();
|
Utilities.checkDisplaySize();
|
||||||
fixLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixLayout() {
|
@Override
|
||||||
if (containerView != null) {
|
public void needLayout() {
|
||||||
ViewTreeObserver obs = containerView.getViewTreeObserver();
|
super.needLayout();
|
||||||
obs.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
if (notificationView != null) {
|
||||||
@Override
|
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
public void onGlobalLayout() {
|
int rotation = manager.getDefaultDisplay().getRotation();
|
||||||
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
||||||
int rotation = manager.getDefaultDisplay().getRotation();
|
|
||||||
|
|
||||||
int height;
|
int height = Utilities.dp(48);
|
||||||
int currentActionBarHeight = getSupportActionBar().getHeight();
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
if (currentActionBarHeight != Utilities.dp(48) && currentActionBarHeight != Utilities.dp(40)) {
|
height = Utilities.dp(40);
|
||||||
height = currentActionBarHeight;
|
}
|
||||||
} else {
|
notificationView.applyOrientationPaddings(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
|
||||||
height = Utilities.dp(48);
|
|
||||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
|
||||||
height = Utilities.dp(40);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notificationView != null) {
|
|
||||||
notificationView.applyOrientationPaddings(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < 16) {
|
|
||||||
containerView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
containerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,22 +641,20 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void didReceivedNotification(int id, Object... args) {
|
public void didReceivedNotification(int id, Object... args) {
|
||||||
if (id == 1234) {
|
if (id == 1234) {
|
||||||
for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
|
for (BaseFragment fragment : fragmentsStack) {
|
||||||
fragment.onFragmentDestroy();
|
fragment.onFragmentDestroy();
|
||||||
}
|
}
|
||||||
ApplicationLoader.fragmentsStack.clear();
|
fragmentsStack.clear();
|
||||||
Intent intent2 = new Intent(this, IntroActivity.class);
|
Intent intent2 = new Intent(this, IntroActivity.class);
|
||||||
startActivity(intent2);
|
startActivity(intent2);
|
||||||
processOnFinish();
|
onFinish();
|
||||||
finish();
|
finish();
|
||||||
} else if (id == GalleryImageViewer.needShowAllMedia) {
|
} else if (id == GalleryImageViewer.needShowAllMedia) {
|
||||||
long dialog_id = (Long)args[0];
|
long dialog_id = (Long)args[0];
|
||||||
MediaActivity fragment = new MediaActivity();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
if (dialog_id != 0) {
|
if (dialog_id != 0) {
|
||||||
bundle.putLong("dialog_id", dialog_id);
|
Bundle args2 = new Bundle();
|
||||||
fragment.setArguments(bundle);
|
args2.putLong("dialog_id", dialog_id);
|
||||||
presentFragment(fragment, "media_" + dialog_id, false);
|
presentFragment(new MediaActivity(args2), false, true);
|
||||||
}
|
}
|
||||||
} else if (id == 658) {
|
} else if (id == 658) {
|
||||||
Integer push_user_id = (Integer)NotificationCenter.getInstance().getFromMemCache("push_user_id", 0);
|
Integer push_user_id = (Integer)NotificationCenter.getInstance().getFromMemCache("push_user_id", 0);
|
||||||
@ -751,46 +663,19 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
|
|
||||||
if (push_user_id != 0) {
|
if (push_user_id != 0) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args2 = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args2.putInt("user_id", push_user_id);
|
||||||
bundle.putInt("user_id", push_user_id);
|
presentFragment(new ChatActivity(args2), false, true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
if (fragment.onFragmentCreate()) {
|
|
||||||
if (ApplicationLoader.fragmentsStack.size() > 0) {
|
|
||||||
BaseFragment lastFragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
lastFragment.willBeHidden();
|
|
||||||
}
|
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
|
|
||||||
}
|
|
||||||
} else if (push_chat_id != 0) {
|
} else if (push_chat_id != 0) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args2 = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args2.putInt("chat_id", push_chat_id);
|
||||||
bundle.putInt("chat_id", push_chat_id);
|
presentFragment(new ChatActivity(args2), false, true);
|
||||||
fragment.setArguments(bundle);
|
} else if (push_enc_id != 0) {
|
||||||
if (fragment.onFragmentCreate()) {
|
|
||||||
if (ApplicationLoader.fragmentsStack.size() > 0) {
|
|
||||||
BaseFragment lastFragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
lastFragment.willBeHidden();
|
|
||||||
}
|
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
|
|
||||||
}
|
|
||||||
} else if (push_enc_id != 0) {
|
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args2 = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args2.putInt("enc_id", push_enc_id);
|
||||||
bundle.putInt("enc_id", push_enc_id);
|
presentFragment(new ChatActivity(args2), false, true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
if (fragment.onFragmentCreate()) {
|
|
||||||
if (ApplicationLoader.fragmentsStack.size() > 0) {
|
|
||||||
BaseFragment lastFragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
lastFragment.willBeHidden();
|
|
||||||
}
|
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (id == 701) {
|
} else if (id == 701) {
|
||||||
if (notificationView != null) {
|
if (notificationView != null) {
|
||||||
@ -799,7 +684,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
}
|
}
|
||||||
} else if (id == 702) {
|
} else if (id == 702) {
|
||||||
if (args[0] != this) {
|
if (args[0] != this) {
|
||||||
processOnFinish();
|
onFinish();
|
||||||
}
|
}
|
||||||
} else if (id == 703) {
|
} else if (id == 703) {
|
||||||
int state = (Integer)args[0];
|
int state = (Integer)args[0];
|
||||||
@ -811,207 +696,33 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fixBackButton() {
|
|
||||||
if(android.os.Build.VERSION.SDK_INT == 19) {
|
|
||||||
//workaround for back button dissapear
|
|
||||||
try {
|
|
||||||
Class firstClass = getSupportActionBar().getClass();
|
|
||||||
Class aClass = firstClass.getSuperclass();
|
|
||||||
if (aClass == android.support.v7.app.ActionBar.class) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Field field = aClass.getDeclaredField("mActionBar");
|
|
||||||
field.setAccessible(true);
|
|
||||||
android.app.ActionBar bar = (android.app.ActionBar)field.get(getSupportActionBar());
|
|
||||||
|
|
||||||
field = bar.getClass().getDeclaredField("mActionView");
|
|
||||||
field.setAccessible(true);
|
|
||||||
View v = (View)field.get(bar);
|
|
||||||
aClass = v.getClass();
|
|
||||||
|
|
||||||
field = aClass.getDeclaredField("mHomeLayout");
|
|
||||||
field.setAccessible(true);
|
|
||||||
v = (View)field.get(v);
|
|
||||||
v.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateActionBar() {
|
public void updateActionBar() {
|
||||||
ActionBar actionBar = getSupportActionBar();
|
if (currentConnectionState != 0 && statusView != null) {
|
||||||
if (actionBar == null) {
|
onShowFragment();
|
||||||
return;
|
if (currentConnectionState == 1) {
|
||||||
}
|
statusText.setText(getString(R.string.WaitingForNetwork));
|
||||||
BaseFragment currentFragment = null;
|
} else if (currentConnectionState == 2) {
|
||||||
if (!ApplicationLoader.fragmentsStack.isEmpty()) {
|
statusText.setText(getString(R.string.Connecting));
|
||||||
currentFragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
} else if (currentConnectionState == 3) {
|
||||||
}
|
statusText.setText(getString(R.string.Updating));
|
||||||
boolean canApplyLoading = true;
|
|
||||||
if (currentFragment != null && (currentConnectionState == 0 || !currentFragment.canApplyUpdateStatus() || statusView == null)) {
|
|
||||||
currentFragment.applySelfActionBar();
|
|
||||||
canApplyLoading = false;
|
|
||||||
}
|
|
||||||
if (canApplyLoading) {
|
|
||||||
if (statusView != null) {
|
|
||||||
statusView.setVisibility(View.VISIBLE);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(true);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
|
|
||||||
if (ApplicationLoader.fragmentsStack.size() > 1) {
|
|
||||||
backStatusButton.setVisibility(View.VISIBLE);
|
|
||||||
statusBackground.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
backStatusButton.setVisibility(View.GONE);
|
|
||||||
statusBackground.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentConnectionState == 1) {
|
|
||||||
statusText.setText(getString(R.string.WaitingForNetwork));
|
|
||||||
} else if (currentConnectionState == 2) {
|
|
||||||
statusText.setText(getString(R.string.Connecting));
|
|
||||||
} else if (currentConnectionState == 3) {
|
|
||||||
statusText.setText(getString(R.string.Updating));
|
|
||||||
}
|
|
||||||
if (actionBar.getCustomView() != statusView) {
|
|
||||||
actionBar.setCustomView(statusView);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (statusView.getLayoutParams() instanceof android.support.v7.app.ActionBar.LayoutParams) {
|
|
||||||
android.support.v7.app.ActionBar.LayoutParams statusParams = (android.support.v7.app.ActionBar.LayoutParams)statusView.getLayoutParams();
|
|
||||||
statusText.measure(View.MeasureSpec.makeMeasureSpec(800, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.AT_MOST));
|
|
||||||
statusParams.width = (statusText.getMeasuredWidth() + Utilities.dp(54));
|
|
||||||
if (statusParams.height == 0) {
|
|
||||||
statusParams.height = actionBar.getHeight();
|
|
||||||
}
|
|
||||||
if (statusParams.width <= 0) {
|
|
||||||
statusParams.width = Utilities.dp(100);
|
|
||||||
}
|
|
||||||
statusParams.topMargin = 0;
|
|
||||||
statusParams.leftMargin = 0;
|
|
||||||
statusView.setLayoutParams(statusParams);
|
|
||||||
} else if (statusView.getLayoutParams() instanceof android.app.ActionBar.LayoutParams) {
|
|
||||||
android.app.ActionBar.LayoutParams statusParams = (android.app.ActionBar.LayoutParams)statusView.getLayoutParams();
|
|
||||||
statusText.measure(View.MeasureSpec.makeMeasureSpec(800, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.AT_MOST));
|
|
||||||
statusParams.width = (statusText.getMeasuredWidth() + Utilities.dp(54));
|
|
||||||
if (statusParams.height == 0) {
|
|
||||||
statusParams.height = actionBar.getHeight();
|
|
||||||
}
|
|
||||||
if (statusParams.width <= 0) {
|
|
||||||
statusParams.width = Utilities.dp(100);
|
|
||||||
}
|
|
||||||
statusParams.topMargin = 0;
|
|
||||||
statusParams.leftMargin = 0;
|
|
||||||
statusView.setLayoutParams(statusParams);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void presentFragment(BaseFragment fragment, String tag, boolean bySwipe) {
|
statusText.measure(View.MeasureSpec.makeMeasureSpec(800, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.AT_MOST));
|
||||||
presentFragment(fragment, tag, false, bySwipe);
|
actionBar.setBackOverlay(statusView, (statusText.getMeasuredWidth() + Utilities.dp(54)));
|
||||||
}
|
} else {
|
||||||
|
actionBar.setBackOverlay(null, 0);
|
||||||
public void presentFragment(BaseFragment fragment, String tag, boolean removeLast, boolean bySwipe) {
|
|
||||||
if (getCurrentFocus() != null) {
|
|
||||||
Utilities.hideKeyboard(getCurrentFocus());
|
|
||||||
}
|
}
|
||||||
if (!fragment.onFragmentCreate()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BaseFragment current = null;
|
|
||||||
if (!ApplicationLoader.fragmentsStack.isEmpty()) {
|
|
||||||
current = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
}
|
|
||||||
if (current != null) {
|
|
||||||
current.willBeHidden();
|
|
||||||
}
|
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
|
||||||
FragmentTransaction fTrans = fm.beginTransaction();
|
|
||||||
if (removeLast && current != null) {
|
|
||||||
ApplicationLoader.fragmentsStack.remove(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
current.onFragmentDestroy();
|
|
||||||
}
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
||||||
boolean animations = preferences.getBoolean("view_animations", true);
|
|
||||||
if (animations) {
|
|
||||||
if (bySwipe) {
|
|
||||||
fTrans.setCustomAnimations(R.anim.slide_left, R.anim.no_anim);
|
|
||||||
} else {
|
|
||||||
fTrans.setCustomAnimations(R.anim.scale_in, R.anim.no_anim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
fTrans.replace(R.id.container, fragment, tag);
|
|
||||||
fTrans.commitAllowingStateLoss();
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeFromStack(BaseFragment fragment) {
|
|
||||||
ApplicationLoader.fragmentsStack.remove(fragment);
|
|
||||||
fragment.onFragmentDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishFragment(boolean bySwipe) {
|
|
||||||
if (getCurrentFocus() != null) {
|
|
||||||
Utilities.hideKeyboard(getCurrentFocus());
|
|
||||||
}
|
|
||||||
if (ApplicationLoader.fragmentsStack.size() < 2) {
|
|
||||||
for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
|
|
||||||
fragment.onFragmentDestroy();
|
|
||||||
}
|
|
||||||
ApplicationLoader.fragmentsStack.clear();
|
|
||||||
MessagesActivity fragment = new MessagesActivity();
|
|
||||||
fragment.onFragmentCreate();
|
|
||||||
ApplicationLoader.fragmentsStack.add(fragment);
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "chats").commitAllowingStateLoss();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BaseFragment fragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
fragment.onFragmentDestroy();
|
|
||||||
BaseFragment prev = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 2);
|
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
|
||||||
FragmentTransaction fTrans = fm.beginTransaction();
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
||||||
boolean animations = preferences.getBoolean("view_animations", true);
|
|
||||||
if (animations) {
|
|
||||||
if (bySwipe) {
|
|
||||||
fTrans.setCustomAnimations(R.anim.no_anim_show, R.anim.slide_right_away);
|
|
||||||
} else {
|
|
||||||
fTrans.setCustomAnimations(R.anim.no_anim_show, R.anim.scale_out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fTrans.replace(R.id.container, prev, prev.getTag());
|
|
||||||
fTrans.commitAllowingStateLoss();
|
|
||||||
ApplicationLoader.fragmentsStack.remove(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
protected void onShowFragment() {
|
||||||
if (ApplicationLoader.fragmentsStack.size() == 1) {
|
if (statusView != null) {
|
||||||
ApplicationLoader.fragmentsStack.get(0).onFragmentDestroy();
|
if (fragmentsStack.size() > 1) {
|
||||||
ApplicationLoader.fragmentsStack.clear();
|
backStatusButton.setVisibility(View.VISIBLE);
|
||||||
processOnFinish();
|
statusBackground.setEnabled(true);
|
||||||
finish();
|
} else {
|
||||||
return;
|
backStatusButton.setVisibility(View.GONE);
|
||||||
}
|
statusBackground.setEnabled(false);
|
||||||
if (!ApplicationLoader.fragmentsStack.isEmpty()) {
|
|
||||||
BaseFragment lastFragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
|
||||||
if (lastFragment.onBackPressed()) {
|
|
||||||
finishFragment(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1020,8 +731,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
try {
|
try {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
if (!ApplicationLoader.fragmentsStack.isEmpty()) {
|
if (!fragmentsStack.isEmpty()) {
|
||||||
BaseFragment lastFragment = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1);
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
Bundle args = lastFragment.getArguments();
|
Bundle args = lastFragment.getArguments();
|
||||||
if (lastFragment instanceof ChatActivity && args != null) {
|
if (lastFragment instanceof ChatActivity && args != null) {
|
||||||
outState.putBundle("args", args);
|
outState.putBundle("args", args);
|
||||||
@ -1033,6 +744,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||||||
outState.putString("fragment", "group");
|
outState.putString("fragment", "group");
|
||||||
} else if (lastFragment instanceof SettingsWallpapersActivity) {
|
} else if (lastFragment instanceof SettingsWallpapersActivity) {
|
||||||
outState.putString("fragment", "wallpapers");
|
outState.putString("fragment", "wallpapers");
|
||||||
|
} else if (lastFragment instanceof ChatProfileActivity && args != null) {
|
||||||
|
outState.putString("fragment", "chat_profile");
|
||||||
}
|
}
|
||||||
lastFragment.saveSelfArgs(outState);
|
lastFragment.saveSelfArgs(outState);
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,7 @@
|
|||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -23,13 +17,15 @@ import android.widget.TextView;
|
|||||||
import com.google.android.gms.maps.CameraUpdate;
|
import com.google.android.gms.maps.CameraUpdate;
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.google.android.gms.maps.SupportMapFragment;
|
import com.google.android.gms.maps.MapView;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.MapsInitializer;
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.android.gms.maps.model.Marker;
|
import com.google.android.gms.maps.model.Marker;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
|
|
||||||
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.objects.MessageObject;
|
import org.telegram.objects.MessageObject;
|
||||||
@ -37,8 +33,11 @@ import org.telegram.messenger.MessagesController;
|
|||||||
import org.telegram.messenger.NotificationCenter;
|
import org.telegram.messenger.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
private GoogleMap googleMap;
|
private GoogleMap googleMap;
|
||||||
@ -49,116 +48,15 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||||||
private MessageObject messageObject;
|
private MessageObject messageObject;
|
||||||
private BackupImageView avatarImageView;
|
private BackupImageView avatarImageView;
|
||||||
private TextView nameTextView;
|
private TextView nameTextView;
|
||||||
private View bottomView;
|
|
||||||
private TextView sendButton;
|
|
||||||
private boolean userLocationMoved = false;
|
private boolean userLocationMoved = false;
|
||||||
private boolean firstWas = false;
|
private boolean firstWas = false;
|
||||||
|
private MapView mapView;
|
||||||
|
|
||||||
private final static int map_to_my_location = 1;
|
private final static int map_to_my_location = 1;
|
||||||
private final static int map_list_menu_map = 2;
|
private final static int map_list_menu_map = 2;
|
||||||
private final static int map_list_menu_satellite = 3;
|
private final static int map_list_menu_satellite = 3;
|
||||||
private final static int map_list_menu_hybrid = 4;
|
private final static int map_list_menu_hybrid = 4;
|
||||||
|
|
||||||
public SupportMapFragment mapFragment = new SupportMapFragment() {
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
googleMap = getMap();
|
|
||||||
if (googleMap == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
googleMap.setMyLocationEnabled(true);
|
|
||||||
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
|
|
||||||
googleMap.getUiSettings().setZoomControlsEnabled(false);
|
|
||||||
googleMap.getUiSettings().setCompassEnabled(false);
|
|
||||||
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onMyLocationChange(Location location) {
|
|
||||||
positionMarker(location);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
myLocation = googleMap.getMyLocation();
|
|
||||||
|
|
||||||
if (sendButton != null) {
|
|
||||||
userLocation = new Location("network");
|
|
||||||
userLocation.setLatitude(20.659322);
|
|
||||||
userLocation.setLongitude(-11.406250);
|
|
||||||
LatLng latLng = new LatLng(20.659322, -11.406250);
|
|
||||||
userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).
|
|
||||||
icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)).draggable(true));
|
|
||||||
|
|
||||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
NotificationCenter.getInstance().postNotificationName(997, userLocation.getLatitude(), userLocation.getLongitude());
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
googleMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
|
|
||||||
@Override
|
|
||||||
public void onMarkerDragStart(Marker marker) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMarkerDrag(Marker marker) {
|
|
||||||
userLocationMoved = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMarkerDragEnd(Marker marker) {
|
|
||||||
LatLng latLng = marker.getPosition();
|
|
||||||
userLocation.setLatitude(latLng.latitude);
|
|
||||||
userLocation.setLongitude(latLng.longitude);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bottomView != null) {
|
|
||||||
bottomView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (userLocation != null) {
|
|
||||||
LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
|
|
||||||
CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
|
|
||||||
googleMap.animateCamera(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messageObject != null) {
|
|
||||||
int fromId = messageObject.messageOwner.from_id;
|
|
||||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
|
||||||
fromId = messageObject.messageOwner.fwd_from_id;
|
|
||||||
}
|
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(fromId);
|
|
||||||
if (user != null) {
|
|
||||||
TLRPC.FileLocation photo = null;
|
|
||||||
if (user.photo != null) {
|
|
||||||
photo = user.photo.photo_small;
|
|
||||||
}
|
|
||||||
avatarImageView.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id));
|
|
||||||
nameTextView.setText(Utilities.formatName(user.first_name, user.last_name));
|
|
||||||
}
|
|
||||||
userLocation = new Location("network");
|
|
||||||
userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
|
|
||||||
userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
|
|
||||||
LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
|
|
||||||
userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).
|
|
||||||
icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)));
|
|
||||||
CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
|
|
||||||
googleMap.moveCamera(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
positionMarker(myLocation);
|
|
||||||
|
|
||||||
ViewGroup topLayout = (ViewGroup)parentActivity.findViewById(R.id.container);
|
|
||||||
topLayout.requestTransparentRegion(topLayout);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
@ -175,57 +73,58 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||||||
super.onFragmentDestroy();
|
super.onFragmentDestroy();
|
||||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.updateInterfaces);
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.updateInterfaces);
|
||||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats);
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats);
|
||||||
}
|
if (mapView != null) {
|
||||||
|
mapView.onDestroy();
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
if (messageObject != null) {
|
|
||||||
actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
|
|
||||||
} else {
|
|
||||||
actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
if (messageObject != null) {
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
|
||||||
|
} else {
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
|
||||||
|
}
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
} else if (id == map_list_menu_map) {
|
||||||
|
if (googleMap != null) {
|
||||||
|
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
|
||||||
|
}
|
||||||
|
} else if (id == map_list_menu_satellite) {
|
||||||
|
if (googleMap != null) {
|
||||||
|
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
|
||||||
|
}
|
||||||
|
} else if (id == map_list_menu_hybrid) {
|
||||||
|
if (googleMap != null) {
|
||||||
|
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
|
||||||
|
}
|
||||||
|
} else if (id == map_to_my_location) {
|
||||||
|
if (myLocation != null) {
|
||||||
|
LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
|
||||||
|
if (googleMap != null) {
|
||||||
|
CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
|
||||||
|
googleMap.animateCamera(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
menu.addItem(map_to_my_location, R.drawable.ic_ab_location);
|
||||||
|
|
||||||
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
||||||
|
item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0);
|
||||||
|
item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0);
|
||||||
|
item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0);
|
||||||
|
|
||||||
if (messageObject != null) {
|
if (messageObject != null) {
|
||||||
fragmentView = inflater.inflate(R.layout.location_view_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.location_view_layout, container, false);
|
||||||
} else {
|
} else {
|
||||||
@ -235,13 +134,108 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||||||
avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view);
|
avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view);
|
||||||
nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label);
|
nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label);
|
||||||
distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label);
|
distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label);
|
||||||
bottomView = fragmentView.findViewById(R.id.location_bottom_view);
|
View bottomView = fragmentView.findViewById(R.id.location_bottom_view);
|
||||||
sendButton = (TextView)fragmentView.findViewById(R.id.location_send_button);
|
TextView sendButton = (TextView) fragmentView.findViewById(R.id.location_send_button);
|
||||||
if (sendButton != null) {
|
if (sendButton != null) {
|
||||||
sendButton.setText(LocaleController.getString("SendLocation", R.string.SendLocation));
|
sendButton.setText(LocaleController.getString("SendLocation", R.string.SendLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildFragmentManager().beginTransaction().replace(R.id.map_view, mapFragment).commit();
|
mapView = (MapView)fragmentView.findViewById(R.id.map_view);
|
||||||
|
mapView.onCreate(null);
|
||||||
|
try {
|
||||||
|
MapsInitializer.initialize(getParentActivity());
|
||||||
|
googleMap = mapView.getMap();
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (googleMap != null) {
|
||||||
|
googleMap.setMyLocationEnabled(true);
|
||||||
|
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
|
||||||
|
googleMap.getUiSettings().setZoomControlsEnabled(false);
|
||||||
|
googleMap.getUiSettings().setCompassEnabled(false);
|
||||||
|
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onMyLocationChange(Location location) {
|
||||||
|
positionMarker(location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
myLocation = googleMap.getMyLocation();
|
||||||
|
|
||||||
|
|
||||||
|
if (sendButton != null) {
|
||||||
|
userLocation = new Location("network");
|
||||||
|
userLocation.setLatitude(20.659322);
|
||||||
|
userLocation.setLongitude(-11.406250);
|
||||||
|
LatLng latLng = new LatLng(20.659322, -11.406250);
|
||||||
|
userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)).draggable(true));
|
||||||
|
|
||||||
|
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
NotificationCenter.getInstance().postNotificationName(997, userLocation.getLatitude(), userLocation.getLongitude());
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
googleMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
|
||||||
|
@Override
|
||||||
|
public void onMarkerDragStart(Marker marker) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkerDrag(Marker marker) {
|
||||||
|
userLocationMoved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkerDragEnd(Marker marker) {
|
||||||
|
LatLng latLng = marker.getPosition();
|
||||||
|
userLocation.setLatitude(latLng.latitude);
|
||||||
|
userLocation.setLongitude(latLng.longitude);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bottomView != null) {
|
||||||
|
bottomView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (userLocation != null) {
|
||||||
|
LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
|
||||||
|
CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
|
||||||
|
googleMap.animateCamera(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messageObject != null) {
|
||||||
|
int fromId = messageObject.messageOwner.from_id;
|
||||||
|
if (messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||||
|
fromId = messageObject.messageOwner.fwd_from_id;
|
||||||
|
}
|
||||||
|
TLRPC.User user = MessagesController.getInstance().users.get(fromId);
|
||||||
|
if (user != null) {
|
||||||
|
TLRPC.FileLocation photo = null;
|
||||||
|
if (user.photo != null) {
|
||||||
|
photo = user.photo.photo_small;
|
||||||
|
}
|
||||||
|
avatarImageView.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id));
|
||||||
|
nameTextView.setText(Utilities.formatName(user.first_name, user.last_name));
|
||||||
|
}
|
||||||
|
userLocation = new Location("network");
|
||||||
|
userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
|
||||||
|
userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
|
||||||
|
LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
|
||||||
|
userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).
|
||||||
|
icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)));
|
||||||
|
CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
|
||||||
|
googleMap.moveCamera(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
positionMarker(myLocation);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -269,51 +263,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
SupportMenuItem item = (SupportMenuItem)menu.add(Menu.NONE, map_to_my_location, Menu.NONE, LocaleController.getString("MyLocation", R.string.MyLocation)).setIcon(R.drawable.ic_ab_location);
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
|
|
||||||
menu.add(Menu.NONE, map_list_menu_map, Menu.NONE, LocaleController.getString("Map", R.string.Map));
|
|
||||||
menu.add(Menu.NONE, map_list_menu_satellite, Menu.NONE, LocaleController.getString("Satellite", R.string.Satellite));
|
|
||||||
menu.add(Menu.NONE, map_list_menu_hybrid, Menu.NONE, LocaleController.getString("Hybrid", R.string.Hybrid));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case map_list_menu_map:
|
|
||||||
if (googleMap != null) {
|
|
||||||
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case map_list_menu_satellite:
|
|
||||||
if (googleMap != null) {
|
|
||||||
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case map_list_menu_hybrid:
|
|
||||||
if (googleMap != null) {
|
|
||||||
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case map_to_my_location:
|
|
||||||
if (myLocation != null) {
|
|
||||||
LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
|
|
||||||
if (googleMap != null) {
|
|
||||||
CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
|
|
||||||
googleMap.animateCamera(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void positionMarker(Location location) {
|
private void positionMarker(Location location) {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return;
|
return;
|
||||||
@ -343,7 +292,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -357,4 +305,28 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||||||
removeSelfFromStack();
|
removeSelfFromStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (mapView != null) {
|
||||||
|
mapView.onPause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mapView != null) {
|
||||||
|
mapView.onResume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {
|
||||||
|
super.onLowMemory();
|
||||||
|
if (mapView != null) {
|
||||||
|
mapView.onLowMemory();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,55 +9,99 @@
|
|||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
import android.view.LayoutInflater;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.Display;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SlideView;
|
import org.telegram.ui.Views.SlideView;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class LoginActivity extends ActionBarActivity implements SlideView.SlideViewDelegate {
|
public class LoginActivity extends BaseFragment implements SlideView.SlideViewDelegate {
|
||||||
private int currentViewNum = 0;
|
private int currentViewNum = 0;
|
||||||
private SlideView[] views = new SlideView[3];
|
private SlideView[] views = new SlideView[3];
|
||||||
|
|
||||||
|
private final static int done_button = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public boolean onFragmentCreate() {
|
||||||
if (currentViewNum == 0) {
|
return super.onFragmentCreate();
|
||||||
if (resultCode == RESULT_OK) {
|
}
|
||||||
((LoginActivityPhoneView)views[0]).selectCountry(data.getStringExtra("country"));
|
|
||||||
|
@Override
|
||||||
|
public void onFragmentDestroy() {
|
||||||
|
super.onFragmentDestroy();
|
||||||
|
for (SlideView v : views) {
|
||||||
|
if (v != null) {
|
||||||
|
v.onDestroyActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Utilities.HideProgressDialog(getParentActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onResume();
|
if (fragmentView == null) {
|
||||||
Utilities.checkForCrashes(this);
|
actionBarLayer.setDisplayUseLogoEnabled(true);
|
||||||
Utilities.checkForUpdates(this);
|
actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
ApplicationLoader.resetLastPauseTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
protected void onPause() {
|
@Override
|
||||||
super.onPause();
|
public void onItemClick(int id) {
|
||||||
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
|
if (id == done_button) {
|
||||||
|
onNextAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout);
|
||||||
|
TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button);
|
||||||
|
doneTextView.setText(LocaleController.getString("Done", R.string.Done));
|
||||||
|
|
||||||
|
fragmentView = inflater.inflate(R.layout.login_layout, container, false);
|
||||||
|
|
||||||
|
views[0] = (SlideView)fragmentView.findViewById(R.id.login_page1);
|
||||||
|
views[1] = (SlideView)fragmentView.findViewById(R.id.login_page2);
|
||||||
|
views[2] = (SlideView)fragmentView.findViewById(R.id.login_page3);
|
||||||
|
|
||||||
|
actionBarLayer.setTitle(views[0].getHeaderName());
|
||||||
|
|
||||||
|
Bundle savedInstanceState = loadCurrentState();
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
|
||||||
|
}
|
||||||
|
for (int a = 0; a < views.length; a++) {
|
||||||
|
SlideView v = views[a];
|
||||||
|
if (v != null) {
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
v.restoreStateParams(savedInstanceState);
|
||||||
|
}
|
||||||
|
v.delegate = this;
|
||||||
|
v.setVisibility(currentViewNum == a ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(fragmentView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCurrentState() {
|
private void saveCurrentState() {
|
||||||
@ -70,7 +114,7 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
v.saveStateParams(bundle);
|
v.saveStateParams(bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
editor.clear();
|
editor.clear();
|
||||||
putBundleToEditor(bundle, editor, null);
|
putBundleToEditor(bundle, editor, null);
|
||||||
@ -83,7 +127,7 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
private Bundle loadCurrentState() {
|
private Bundle loadCurrentState() {
|
||||||
try {
|
try {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", Context.MODE_PRIVATE);
|
||||||
Map<String, ?> params = preferences.getAll();
|
Map<String, ?> params = preferences.getAll();
|
||||||
for (Map.Entry<String, ?> entry : params.entrySet()) {
|
for (Map.Entry<String, ?> entry : params.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
@ -116,7 +160,7 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearCurrentState() {
|
private void clearCurrentState() {
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
editor.clear();
|
editor.clear();
|
||||||
editor.commit();
|
editor.commit();
|
||||||
@ -144,125 +188,58 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowAlertDialog(final Activity activity, final String message) {
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!isFinishing()) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
||||||
builder.setMessage(message);
|
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
||||||
builder.show().setCanceledOnTouchOutside(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public boolean onBackPressed() {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.login_layout);
|
|
||||||
ApplicationLoader.applicationContext = this.getApplicationContext();
|
|
||||||
|
|
||||||
getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2);
|
|
||||||
getSupportActionBar().show();
|
|
||||||
|
|
||||||
ImageView view = (ImageView)findViewById(16908332);
|
|
||||||
if (view == null) {
|
|
||||||
view = (ImageView)findViewById(R.id.home);
|
|
||||||
}
|
|
||||||
if (view != null) {
|
|
||||||
view.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
views[0] = (SlideView)findViewById(R.id.login_page1);
|
|
||||||
views[1] = (SlideView)findViewById(R.id.login_page2);
|
|
||||||
views[2] = (SlideView)findViewById(R.id.login_page3);
|
|
||||||
|
|
||||||
getSupportActionBar().setTitle(views[0].getHeaderName());
|
|
||||||
|
|
||||||
savedInstanceState = loadCurrentState();
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
|
|
||||||
}
|
|
||||||
for (int a = 0; a < views.length; a++) {
|
|
||||||
SlideView v = views[a];
|
|
||||||
if (v != null) {
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
v.restoreStateParams(savedInstanceState);
|
|
||||||
}
|
|
||||||
v.delegate = this;
|
|
||||||
v.setVisibility(currentViewNum == a ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
SupportMenuItem doneItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, null);
|
|
||||||
doneItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
doneItem.setActionView(R.layout.group_create_done_layout);
|
|
||||||
|
|
||||||
TextView doneTextView = (TextView)doneItem.getActionView().findViewById(R.id.done_button);
|
|
||||||
doneTextView.setText(LocaleController.getString("Done", R.string.Done));
|
|
||||||
doneTextView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
onNextAction();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if (currentViewNum == 0) {
|
if (currentViewNum == 0) {
|
||||||
for (SlideView v : views) {
|
for (SlideView v : views) {
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
v.onDestroyActivity();
|
v.onDestroyActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onBackPressed();
|
return true;
|
||||||
} else if (currentViewNum != 1 && currentViewNum != 2) {
|
} else if (currentViewNum != 1 && currentViewNum != 2) {
|
||||||
setPage(0, true, null, true);
|
setPage(0, true, null, true);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void needShowAlert(String text) {
|
public void needShowAlert(final String text) {
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ShowAlertDialog(LoginActivity.this, text);
|
getParentActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
|
builder.setMessage(text);
|
||||||
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
||||||
|
builder.show().setCanceledOnTouchOutside(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void needShowProgress() {
|
public void needShowProgress() {
|
||||||
Utilities.ShowProgressDialog(this, LocaleController.getString("Loading", R.string.Loading));
|
Utilities.ShowProgressDialog(getParentActivity(), LocaleController.getString("Loading", R.string.Loading));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void needHideProgress() {
|
public void needHideProgress() {
|
||||||
Utilities.HideProgressDialog(this);
|
Utilities.HideProgressDialog(getParentActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPage(int page, boolean animated, Bundle params, boolean back) {
|
public void setPage(int page, boolean animated, Bundle params, boolean back) {
|
||||||
if(android.os.Build.VERSION.SDK_INT > 13) {
|
if(android.os.Build.VERSION.SDK_INT > 13) {
|
||||||
Point displaySize = new Point();
|
|
||||||
Display display = getWindowManager().getDefaultDisplay();
|
|
||||||
display.getSize(displaySize);
|
|
||||||
|
|
||||||
final SlideView outView = views[currentViewNum];
|
final SlideView outView = views[currentViewNum];
|
||||||
final SlideView newView = views[page];
|
final SlideView newView = views[page];
|
||||||
currentViewNum = page;
|
currentViewNum = page;
|
||||||
|
|
||||||
newView.setParams(params);
|
newView.setParams(params);
|
||||||
getSupportActionBar().setTitle(newView.getHeaderName());
|
actionBarLayer.setTitle(newView.getHeaderName());
|
||||||
newView.onShow();
|
newView.onShow();
|
||||||
newView.setX(back ? -displaySize.x : displaySize.x);
|
newView.setX(back ? -Utilities.displaySize.x : Utilities.displaySize.x);
|
||||||
outView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
outView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animator animator) {
|
public void onAnimationStart(Animator animator) {
|
||||||
@ -281,7 +258,7 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationRepeat(Animator animator) {
|
public void onAnimationRepeat(Animator animator) {
|
||||||
}
|
}
|
||||||
}).setDuration(300).translationX(back ? displaySize.x : -displaySize.x).start();
|
}).setDuration(300).translationX(back ? Utilities.displaySize.x : -Utilities.displaySize.x).start();
|
||||||
newView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
newView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animator animator) {
|
public void onAnimationStart(Animator animator) {
|
||||||
@ -305,7 +282,7 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
currentViewNum = page;
|
currentViewNum = page;
|
||||||
views[page].setParams(params);
|
views[page].setParams(params);
|
||||||
views[page].setVisibility(View.VISIBLE);
|
views[page].setVisibility(View.VISIBLE);
|
||||||
getSupportActionBar().setTitle(views[page].getHeaderName());
|
actionBarLayer.setTitle(views[page].getHeaderName());
|
||||||
views[page].onShow();
|
views[page].onShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,27 +293,13 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
public void saveSelfArgs(Bundle outState) {
|
||||||
super.onDestroy();
|
|
||||||
for (SlideView v : views) {
|
|
||||||
if (v != null) {
|
|
||||||
v.onDestroyActivity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Utilities.HideProgressDialog(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
saveCurrentState();
|
saveCurrentState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void needFinishActivity() {
|
public void needFinishActivity() {
|
||||||
Intent intent2 = new Intent(this, LaunchActivity.class);
|
|
||||||
startActivity(intent2);
|
|
||||||
finish();
|
|
||||||
clearCurrentState();
|
clearCurrentState();
|
||||||
|
presentFragment(new MessagesActivity(null), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
package org.telegram.ui;
|
package org.telegram.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
@ -33,6 +31,7 @@ import org.telegram.messenger.FileLog;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.SlideView;
|
import org.telegram.ui.Views.SlideView;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -82,9 +81,16 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
|
|||||||
countryButton.setOnClickListener(new OnClickListener() {
|
countryButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
ActionBarActivity activity = (ActionBarActivity)delegate;
|
BaseFragment activity = (BaseFragment)delegate;
|
||||||
Intent intent = new Intent(activity, CountrySelectActivity.class);
|
CountrySelectActivity fragment = new CountrySelectActivity();
|
||||||
activity.startActivityForResult(intent, 1);
|
fragment.setCountrySelectActivityDelegate(new CountrySelectActivity.CountrySelectActivityDelegate() {
|
||||||
|
@Override
|
||||||
|
public void didSelectCountry(String name) {
|
||||||
|
selectCountry(name);
|
||||||
|
phoneField.requestFocus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
activity.presentFragment(fragment);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,9 +13,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -34,9 +32,9 @@ import org.telegram.objects.MessageObject;
|
|||||||
import org.telegram.messenger.MessagesController;
|
import org.telegram.messenger.MessagesController;
|
||||||
import org.telegram.messenger.NotificationCenter;
|
import org.telegram.messenger.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -57,6 +55,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
private View progressView;
|
private View progressView;
|
||||||
private TextView emptyView;
|
private TextView emptyView;
|
||||||
|
|
||||||
|
public MediaActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
@ -83,14 +85,24 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia));
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
if (Build.VERSION.SDK_INT < 11) {
|
||||||
|
listView.setAdapter(null);
|
||||||
|
listView = null;
|
||||||
|
listAdapter = null;
|
||||||
|
}
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.media_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.media_layout, container, false);
|
||||||
|
|
||||||
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
@ -98,14 +110,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
listView = (GridView)fragmentView.findViewById(R.id.media_grid);
|
listView = (GridView)fragmentView.findViewById(R.id.media_grid);
|
||||||
progressView = fragmentView.findViewById(R.id.progressLayout);
|
progressView = fragmentView.findViewById(R.id.progressLayout);
|
||||||
|
|
||||||
listView.setAdapter(listAdapter = new ListAdapter(parentActivity));
|
listView.setAdapter(listAdapter = new ListAdapter(getParentActivity()));
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
NotificationCenter.getInstance().addToMemCache(54, messages);
|
NotificationCenter.getInstance().addToMemCache(54, messages);
|
||||||
NotificationCenter.getInstance().addToMemCache(55, i);
|
NotificationCenter.getInstance().addToMemCache(55, i);
|
||||||
Intent intent = new Intent(parentActivity, GalleryImageViewer.class);
|
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (loading && messages.isEmpty()) {
|
if (loading && messages.isEmpty()) {
|
||||||
@ -130,17 +142,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
emptyView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -250,44 +251,11 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia));
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listAdapter != null) {
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
fixLayout();
|
fixLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,24 +271,23 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreDraw() {
|
public boolean onPreDraw() {
|
||||||
if (parentActivity != null) {
|
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||||
WindowManager manager = (WindowManager)parentActivity.getSystemService(Activity.WINDOW_SERVICE);
|
int rotation = manager.getDefaultDisplay().getRotation();
|
||||||
int rotation = manager.getDefaultDisplay().getRotation();
|
|
||||||
|
|
||||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||||
orientation = 1;
|
orientation = 1;
|
||||||
listView.setNumColumns(6);
|
listView.setNumColumns(6);
|
||||||
itemWidth = getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5;
|
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5;
|
||||||
listView.setColumnWidth(itemWidth);
|
listView.setColumnWidth(itemWidth);
|
||||||
} else {
|
} else {
|
||||||
orientation = 0;
|
orientation = 0;
|
||||||
listView.setNumColumns(4);
|
listView.setNumColumns(4);
|
||||||
itemWidth = getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3;
|
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3;
|
||||||
listView.setColumnWidth(itemWidth);
|
listView.setColumnWidth(itemWidth);
|
||||||
}
|
|
||||||
listView.setPadding(listView.getPaddingLeft(), Utilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom());
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
listView.setPadding(listView.getPaddingLeft(), Utilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom());
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
if (listView != null) {
|
if (listView != null) {
|
||||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
}
|
}
|
||||||
@ -331,22 +298,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
if (Build.VERSION.SDK_INT < 11) {
|
|
||||||
listView.setAdapter(null);
|
|
||||||
listView = null;
|
|
||||||
listAdapter = null;
|
|
||||||
}
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ListAdapter extends BaseAdapter {
|
private class ListAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@ -403,13 +354,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||||||
if (message.messageOwner.media != null && message.messageOwner.media.photo != null && !message.messageOwner.media.photo.sizes.isEmpty()) {
|
if (message.messageOwner.media != null && message.messageOwner.media.photo != null && !message.messageOwner.media.photo.sizes.isEmpty()) {
|
||||||
ArrayList<TLRPC.PhotoSize> sizes = message.messageOwner.media.photo.sizes;
|
ArrayList<TLRPC.PhotoSize> sizes = message.messageOwner.media.photo.sizes;
|
||||||
boolean set = false;
|
boolean set = false;
|
||||||
// for (TLRPC.PhotoSize size : sizes) {
|
|
||||||
// if (size.type != null && size.type.equals("m")) {
|
|
||||||
// set = true;
|
|
||||||
// imageView.setImage(size.location, null, R.drawable.photo_placeholder);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (!set) {
|
if (!set) {
|
||||||
if (message.imagePreview != null) {
|
if (message.imagePreview != null) {
|
||||||
imageView.setImageBitmap(message.imagePreview);
|
imageView.setImageBitmap(message.imagePreview);
|
||||||
|
@ -12,21 +12,13 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -43,9 +35,11 @@ import org.telegram.messenger.UserConfig;
|
|||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||||
import org.telegram.ui.Cells.DialogCell;
|
import org.telegram.ui.Cells.DialogCell;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
@ -55,11 +49,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
private MessagesAdapter messagesListViewAdapter;
|
private MessagesAdapter messagesListViewAdapter;
|
||||||
private TextView searchEmptyView;
|
private TextView searchEmptyView;
|
||||||
private View progressView;
|
private View progressView;
|
||||||
private SupportMenuItem searchItem;
|
|
||||||
private View empryView;
|
private View empryView;
|
||||||
private SearchView searchView;
|
private String selectAlertString;
|
||||||
public int selectAlertString = 0;
|
|
||||||
public String selectAlertStringDesc = null;
|
|
||||||
private boolean serverOnly = false;
|
private boolean serverOnly = false;
|
||||||
|
|
||||||
private static boolean dialogsLoaded = false;
|
private static boolean dialogsLoaded = false;
|
||||||
@ -73,10 +64,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
public ArrayList<TLObject> searchResult;
|
public ArrayList<TLObject> searchResult;
|
||||||
public ArrayList<CharSequence> searchResultNames;
|
public ArrayList<CharSequence> searchResultNames;
|
||||||
|
|
||||||
public MessagesActivityDelegate delegate;
|
private MessagesActivityDelegate delegate;
|
||||||
|
|
||||||
private final static int messages_list_menu_new_messages = 1;
|
private final static int messages_list_menu_new_messages = 1;
|
||||||
private final static int messages_list_menu_new_chat = 2;
|
private final static int messages_list_menu_new_chat = 2;
|
||||||
|
private final static int messages_list_menu_other = 6;
|
||||||
private final static int messages_list_menu_new_secret_chat = 3;
|
private final static int messages_list_menu_new_secret_chat = 3;
|
||||||
private final static int messages_list_menu_contacts = 4;
|
private final static int messages_list_menu_contacts = 4;
|
||||||
private final static int messages_list_menu_settings = 5;
|
private final static int messages_list_menu_settings = 5;
|
||||||
@ -85,6 +77,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id);
|
public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessagesActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
@ -96,8 +92,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
||||||
NotificationCenter.getInstance().addObserver(this, 1234);
|
NotificationCenter.getInstance().addObserver(this, 1234);
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
onlySelect = getArguments().getBoolean("onlySelect", false);
|
onlySelect = arguments.getBoolean("onlySelect", false);
|
||||||
serverOnly = getArguments().getBoolean("serverOnly", false);
|
serverOnly = arguments.getBoolean("serverOnly", false);
|
||||||
|
selectAlertString = arguments.getString("selectAlertString");
|
||||||
}
|
}
|
||||||
if (!dialogsLoaded) {
|
if (!dialogsLoaded) {
|
||||||
MessagesController.getInstance().loadDialogs(0, 0, 100, true);
|
MessagesController.getInstance().loadDialogs(0, 0, 100, true);
|
||||||
@ -121,20 +118,101 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||||
|
@Override
|
||||||
|
public void onSearchExpand() {
|
||||||
|
searching = true;
|
||||||
|
if (messagesListView != null) {
|
||||||
|
messagesListView.setEmptyView(searchEmptyView);
|
||||||
|
}
|
||||||
|
if (empryView != null) {
|
||||||
|
empryView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSearchCollapse() {
|
||||||
|
searchDialogs(null);
|
||||||
|
searching = false;
|
||||||
|
searchWas = false;
|
||||||
|
if (messagesListView != null) {
|
||||||
|
messagesListView.setEmptyView(empryView);
|
||||||
|
searchEmptyView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
if (messagesListViewAdapter != null) {
|
||||||
|
messagesListViewAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(EditText editText) {
|
||||||
|
String text = editText.getText().toString();
|
||||||
|
searchDialogs(text);
|
||||||
|
if (text.length() != 0) {
|
||||||
|
searchWas = true;
|
||||||
|
if (messagesListViewAdapter != null) {
|
||||||
|
messagesListViewAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
if (searchEmptyView != null) {
|
||||||
|
messagesListView.setEmptyView(searchEmptyView);
|
||||||
|
empryView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (onlySelect) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
||||||
|
} else {
|
||||||
|
actionBarLayer.setDisplayUseLogoEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
|
menu.addItem(messages_list_menu_new_messages, R.drawable.ic_ab_compose);
|
||||||
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
||||||
|
item.addSubItem(messages_list_menu_new_chat, LocaleController.getString("NewGroup", R.string.NewGroup), 0);
|
||||||
|
item.addSubItem(messages_list_menu_new_secret_chat, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), 0);
|
||||||
|
item.addSubItem(messages_list_menu_contacts, LocaleController.getString("Contacts", R.string.Contacts), 0);
|
||||||
|
item.addSubItem(messages_list_menu_settings, LocaleController.getString("Settings", R.string.Settings), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == messages_list_menu_settings) {
|
||||||
|
presentFragment(new SettingsActivity());
|
||||||
|
} else if (id == messages_list_menu_contacts) {
|
||||||
|
presentFragment(new ContactsActivity(null));
|
||||||
|
} else if (id == messages_list_menu_new_messages) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("onlyUsers", true);
|
||||||
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
|
args.putBoolean("usersAsSections", true);
|
||||||
|
presentFragment(new ContactsActivity(args));
|
||||||
|
} else if (id == messages_list_menu_new_secret_chat) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("onlyUsers", true);
|
||||||
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
|
args.putBoolean("usersAsSections", true);
|
||||||
|
args.putBoolean("createSecretChat", true);
|
||||||
|
presentFragment(new ContactsActivity(args));
|
||||||
|
} else if (id == messages_list_menu_new_chat) {
|
||||||
|
presentFragment(new GroupCreateActivity());
|
||||||
|
} else if (id == -1) {
|
||||||
|
if (onlySelect) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
|
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
|
||||||
|
|
||||||
messagesListViewAdapter = new MessagesAdapter(parentActivity);
|
messagesListViewAdapter = new MessagesAdapter(getParentActivity());
|
||||||
|
|
||||||
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
||||||
messagesListView.setAdapter(messagesListViewAdapter);
|
messagesListView.setAdapter(messagesListViewAdapter);
|
||||||
@ -199,25 +277,18 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (onlySelect) {
|
if (onlySelect) {
|
||||||
didSelectResult(dialog_id, true);
|
didSelectResult(dialog_id, true);
|
||||||
} else {
|
} else {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
int lower_part = (int)dialog_id;
|
int lower_part = (int)dialog_id;
|
||||||
if (lower_part != 0) {
|
if (lower_part != 0) {
|
||||||
if (lower_part > 0) {
|
if (lower_part > 0) {
|
||||||
bundle.putInt("user_id", lower_part);
|
args.putInt("user_id", lower_part);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
|
|
||||||
} else if (lower_part < 0) {
|
} else if (lower_part < 0) {
|
||||||
bundle.putInt("chat_id", -lower_part);
|
args.putInt("chat_id", -lower_part);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int id = (int)(dialog_id >> 32);
|
args.putInt("enc_id", (int)(dialog_id >> 32));
|
||||||
bundle.putInt("enc_id", id);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
|
|
||||||
}
|
}
|
||||||
|
presentFragment(new ChatActivity(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -242,7 +313,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
selectedDialog = dialog.id;
|
selectedDialog = dialog.id;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
|
|
||||||
if ((int)selectedDialog < 0) {
|
if ((int)selectedDialog < 0) {
|
||||||
@ -275,7 +346,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||||
Utilities.hideKeyboard(searchView);
|
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,75 +376,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
if (onlySelect) {
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
} else {
|
|
||||||
ImageView view = (ImageView)parentActivity.findViewById(16908332);
|
|
||||||
if (view == null) {
|
|
||||||
view = (ImageView)parentActivity.findViewById(R.id.home);
|
|
||||||
}
|
|
||||||
if (view != null) {
|
|
||||||
view.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
|
|
||||||
}
|
|
||||||
actionBar.setHomeButtonEnabled(false);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(true);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(true);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
showActionBar();
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (messagesListViewAdapter != null) {
|
if (messagesListViewAdapter != null) {
|
||||||
messagesListViewAdapter.notifyDataSetChanged();
|
messagesListViewAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
actionBarLayer.closeSearchField();
|
||||||
if (searchItem != null && searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -439,18 +452,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setDelegate(MessagesActivityDelegate delegate) {
|
||||||
public void willBeHidden() {
|
this.delegate = delegate;
|
||||||
if (searchItem != null) {
|
|
||||||
if (searchItem.isActionViewExpanded()) {
|
|
||||||
searchItem.collapseActionView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void didSelectResult(final long dialog_id, boolean useAlert) {
|
private void didSelectResult(final long dialog_id, boolean useAlert) {
|
||||||
if (useAlert && selectAlertString != 0) {
|
if (useAlert && selectAlertString != null) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
int lower_part = (int)dialog_id;
|
int lower_part = (int)dialog_id;
|
||||||
if (lower_part != 0) {
|
if (lower_part != 0) {
|
||||||
@ -459,13 +467,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (user == null) {
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
|
||||||
} else if (lower_part < 0) {
|
} else if (lower_part < 0) {
|
||||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
|
TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
|
||||||
if (chat == null) {
|
if (chat == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, chat.title));
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int chat_id = (int)(dialog_id >> 32);
|
int chat_id = (int)(dialog_id >> 32);
|
||||||
@ -474,7 +482,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (user == null) {
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
|
||||||
}
|
}
|
||||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -550,167 +558,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
searchItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, LocaleController.getString("Search", R.string.Search)).setIcon(R.drawable.ic_ab_search);
|
|
||||||
searchItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS|SupportMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
||||||
searchItem.setActionView(searchView = new SearchView(parentActivity));
|
|
||||||
if (!onlySelect) {
|
|
||||||
SupportMenuItem item = (SupportMenuItem)menu.add(Menu.NONE, messages_list_menu_new_messages, Menu.NONE, LocaleController.getString("NewMessages", R.string.NewMessages)).setIcon(R.drawable.ic_ab_compose);
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
|
|
||||||
item = (SupportMenuItem)menu.add(Menu.NONE, messages_list_menu_new_chat, Menu.NONE, LocaleController.getString("NewGroup", R.string.NewGroup));
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
|
|
||||||
item = (SupportMenuItem)menu.add(Menu.NONE, messages_list_menu_new_secret_chat, Menu.NONE, LocaleController.getString("NewSecretChat", R.string.NewSecretChat));
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
|
|
||||||
item = (SupportMenuItem)menu.add(Menu.NONE, messages_list_menu_contacts, Menu.NONE, LocaleController.getString("Contacts", R.string.Contacts));
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
|
|
||||||
item = (SupportMenuItem)menu.add(Menu.NONE, messages_list_menu_settings, Menu.NONE, LocaleController.getString("Settings", R.string.Settings));
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView textView = (TextView) searchView.findViewById(R.id.search_src_text);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setTextColor(0xffffffff);
|
|
||||||
try {
|
|
||||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
|
||||||
mCursorDrawableRes.setAccessible(true);
|
|
||||||
mCursorDrawableRes.set(textView, R.drawable.search_carret);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
|
|
||||||
if (img != null) {
|
|
||||||
img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextSubmit(String s) {
|
|
||||||
Utilities.hideKeyboard(searchView);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextChange(String s) {
|
|
||||||
searchDialogs(s);
|
|
||||||
if (s.length() != 0) {
|
|
||||||
searchWas = true;
|
|
||||||
if (messagesListViewAdapter != null) {
|
|
||||||
messagesListViewAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
if (searchEmptyView != null) {
|
|
||||||
messagesListView.setEmptyView(searchEmptyView);
|
|
||||||
empryView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchItem.setSupportOnActionExpandListener(new MenuItemCompat.OnActionExpandListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
|
||||||
if (parentActivity != null) {
|
|
||||||
parentActivity.getSupportActionBar().setIcon(R.drawable.ic_ab_logo);
|
|
||||||
}
|
|
||||||
searching = true;
|
|
||||||
if (messagesListView != null) {
|
|
||||||
messagesListView.setEmptyView(searchEmptyView);
|
|
||||||
}
|
|
||||||
if (empryView != null) {
|
|
||||||
empryView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
|
||||||
searchView.setQuery("", false);
|
|
||||||
searchDialogs(null);
|
|
||||||
searching = false;
|
|
||||||
searchWas = false;
|
|
||||||
if (messagesListView != null) {
|
|
||||||
messagesListView.setEmptyView(empryView);
|
|
||||||
searchEmptyView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
if (messagesListViewAdapter != null) {
|
|
||||||
messagesListViewAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
if (onlySelect) {
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
FragmentActivity inflaterActivity = parentActivity;
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
inflaterActivity = getActivity();
|
|
||||||
}
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (itemId) {
|
|
||||||
|
|
||||||
case messages_list_menu_settings: {
|
|
||||||
((LaunchActivity)inflaterActivity).presentFragment(new SettingsActivity(), "settings", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case messages_list_menu_contacts: {
|
|
||||||
((LaunchActivity)inflaterActivity).presentFragment(new ContactsActivity(), "contacts", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case messages_list_menu_new_messages: {
|
|
||||||
BaseFragment fragment = new ContactsActivity();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean("onlyUsers", true);
|
|
||||||
bundle.putBoolean("destroyAfterSelect", true);
|
|
||||||
bundle.putBoolean("usersAsSections", true);
|
|
||||||
fragment.animationType = 1;
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)inflaterActivity).presentFragment(fragment, "contacts_chat", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case messages_list_menu_new_secret_chat: {
|
|
||||||
BaseFragment fragment = new ContactsActivity();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean("onlyUsers", true);
|
|
||||||
bundle.putBoolean("destroyAfterSelect", true);
|
|
||||||
bundle.putBoolean("usersAsSections", true);
|
|
||||||
bundle.putBoolean("createSecretChat", true);
|
|
||||||
fragment.animationType = 1;
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)inflaterActivity).presentFragment(fragment, "contacts_chat", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case messages_list_menu_new_chat: {
|
|
||||||
((LaunchActivity)inflaterActivity).presentFragment(new GroupCreateActivity(), "group_create", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case android.R.id.home:
|
|
||||||
if (onlySelect) {
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MessagesAdapter extends BaseAdapter {
|
private class MessagesAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import android.graphics.Point;
|
|||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -33,7 +32,7 @@ import org.telegram.messenger.FileLog;
|
|||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -278,14 +277,17 @@ public class PhotoCropActivity extends BaseFragment {
|
|||||||
|
|
||||||
private Bitmap imageToCrop;
|
private Bitmap imageToCrop;
|
||||||
private BitmapDrawable drawable;
|
private BitmapDrawable drawable;
|
||||||
public PhotoCropActivityDelegate delegate = null;
|
private PhotoCropActivityDelegate delegate = null;
|
||||||
private PhotoCropView view;
|
private PhotoCropView view;
|
||||||
private boolean sameBitmap = false;
|
private boolean sameBitmap = false;
|
||||||
private boolean doneButtonPressed = false;
|
private boolean doneButtonPressed = false;
|
||||||
|
|
||||||
|
public PhotoCropActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
|
||||||
String photoPath = getArguments().getString("photoPath");
|
String photoPath = getArguments().getString("photoPath");
|
||||||
Uri photoUri = getArguments().getParcelable("photoUri");
|
Uri photoUri = getArguments().getParcelable("photoUri");
|
||||||
if (photoPath == null && photoUri == null) {
|
if (photoPath == null && photoUri == null) {
|
||||||
@ -310,6 +312,7 @@ public class PhotoCropActivity extends BaseFragment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
drawable = new BitmapDrawable(imageToCrop);
|
drawable = new BitmapDrawable(imageToCrop);
|
||||||
|
super.onFragmentCreate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,14 +327,37 @@ public class PhotoCropActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
fragmentView = view = new PhotoCropView(this.getActivity());
|
actionBarLayer.setCustomView(R.layout.settings_do_action_layout);
|
||||||
|
Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button);
|
||||||
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
View doneButton = actionBarLayer.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;
|
||||||
|
}
|
||||||
|
delegate.didFinishCrop(bitmap);
|
||||||
|
doneButtonPressed = true;
|
||||||
|
}
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
||||||
|
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||||
|
textView.setText(LocaleController.getString("Done", R.string.Done));
|
||||||
|
|
||||||
|
fragmentView = view = new PhotoCropView(getParentActivity());
|
||||||
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
@ -342,57 +368,7 @@ public class PhotoCropActivity extends BaseFragment {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setDelegate(PhotoCropActivityDelegate delegate) {
|
||||||
public boolean canApplyUpdateStatus() {
|
this.delegate = delegate;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowCustomEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
|
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
|
||||||
Button cancelButton = (Button)actionBar.getCustomView().findViewById(R.id.cancel_button);
|
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
View doneButton = actionBar.getCustomView().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;
|
|
||||||
}
|
|
||||||
delegate.didFinishCrop(bitmap);
|
|
||||||
doneButtonPressed = true;
|
|
||||||
}
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,11 @@ import android.content.pm.PackageInfo;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -55,10 +52,10 @@ import org.telegram.messenger.RPCRequest;
|
|||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.objects.PhotoObject;
|
import org.telegram.objects.PhotoObject;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.AvatarUpdater;
|
import org.telegram.ui.Views.AvatarUpdater;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -220,26 +217,28 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("Settings", R.string.Settings));
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.settings_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.settings_layout, container, false);
|
||||||
listAdapter = new ListAdapter(parentActivity);
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (i == textSizeRow) {
|
if (i == textSizeRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("TextSize", R.string.TextSize));
|
builder.setTitle(LocaleController.getString("TextSize", R.string.TextSize));
|
||||||
builder.setItems(new CharSequence[]{String.format("%d", 12), String.format("%d", 13), String.format("%d", 14), String.format("%d", 15), String.format("%d", 16), String.format("%d", 17), String.format("%d", 18), String.format("%d", 19), String.format("%d", 20), String.format("%d", 21), String.format("%d", 22), String.format("%d", 23), String.format("%d", 24)}, new DialogInterface.OnClickListener() {
|
builder.setItems(new CharSequence[]{String.format("%d", 12), String.format("%d", 13), String.format("%d", 14), String.format("%d", 15), String.format("%d", 16), String.format("%d", 17), String.format("%d", 18), String.format("%d", 19), String.format("%d", 20), String.format("%d", 21), String.format("%d", 22), String.format("%d", 23), String.format("%d", 24)}, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -266,19 +265,19 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
}
|
}
|
||||||
} else if (i == notificationRow) {
|
} else if (i == notificationRow) {
|
||||||
((LaunchActivity)parentActivity).presentFragment(new SettingsNotificationsActivity(), "settings_notifications", false);
|
presentFragment(new SettingsNotificationsActivity());
|
||||||
} else if (i == blockedRow) {
|
} else if (i == blockedRow) {
|
||||||
((LaunchActivity)parentActivity).presentFragment(new SettingsBlockedUsers(), "settings_blocked", false);
|
presentFragment(new SettingsBlockedUsers());
|
||||||
} else if (i == backgroundRow) {
|
} else if (i == backgroundRow) {
|
||||||
((LaunchActivity)parentActivity).presentFragment(new SettingsWallpapersActivity(), "settings_wallpapers", false);
|
presentFragment(new SettingsWallpapersActivity());
|
||||||
} else if (i == askQuestionRow) {
|
} else if (i == askQuestionRow) {
|
||||||
final TextView message = new TextView(parentActivity);
|
final TextView message = new TextView(getParentActivity());
|
||||||
message.setText(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo)));
|
message.setText(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo)));
|
||||||
message.setTextSize(18);
|
message.setTextSize(18);
|
||||||
message.setPadding(Utilities.dp(8), Utilities.dp(5), Utilities.dp(8), Utilities.dp(6));
|
message.setPadding(Utilities.dp(8), Utilities.dp(5), Utilities.dp(8), Utilities.dp(6));
|
||||||
message.setMovementMethod(new LinkMovementMethodMy());
|
message.setMovementMethod(new LinkMovementMethodMy());
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setView(message);
|
builder.setView(message);
|
||||||
builder.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -302,7 +301,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
}
|
}
|
||||||
} else if (i == terminateSessionsRow) {
|
} else if (i == terminateSessionsRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
@ -312,18 +311,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
ActionBarActivity inflaterActivity = parentActivity;
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
inflaterActivity = (ActionBarActivity)getActivity();
|
|
||||||
}
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (error == null && response instanceof TLRPC.TL_boolTrue) {
|
if (error == null && response instanceof TLRPC.TL_boolTrue) {
|
||||||
Toast toast = Toast.makeText(inflaterActivity, R.string.TerminateAllSessions, Toast.LENGTH_SHORT);
|
Toast toast = Toast.makeText(getParentActivity(), R.string.TerminateAllSessions, Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
} else {
|
} else {
|
||||||
Toast toast = Toast.makeText(inflaterActivity, R.string.UnknownError, Toast.LENGTH_SHORT);
|
Toast toast = Toast.makeText(getParentActivity(), R.string.UnknownError, Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
UserConfig.registeredForPush = false;
|
UserConfig.registeredForPush = false;
|
||||||
@ -335,9 +327,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
builder.show().setCanceledOnTouchOutside(true);
|
builder.show().setCanceledOnTouchOutside(true);
|
||||||
} else if (i == languageRow) {
|
} else if (i == languageRow) {
|
||||||
((LaunchActivity)parentActivity).presentFragment(new LanguageSelectActivity(), "settings_lang", false);
|
presentFragment(new LanguageSelectActivity());
|
||||||
} else if (i == switchBackendButtonRow) {
|
} else if (i == switchBackendButtonRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
@ -351,14 +343,14 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
} else if (i == telegramFaqRow) {
|
} else if (i == telegramFaqRow) {
|
||||||
try {
|
try {
|
||||||
Intent pickIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)));
|
Intent pickIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)));
|
||||||
parentActivity.startActivity(pickIntent);
|
getParentActivity().startActivity(pickIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
} else if (i == contactsReimportRow) {
|
} else if (i == contactsReimportRow) {
|
||||||
|
|
||||||
} else if (i == contactsSortRow) {
|
} else if (i == contactsSortRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("SortBy", R.string.SortBy));
|
builder.setTitle(LocaleController.getString("SortBy", R.string.SortBy));
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
LocaleController.getString("Default", R.string.Default),
|
LocaleController.getString("Default", R.string.Default),
|
||||||
@ -379,7 +371,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
builder.show().setCanceledOnTouchOutside(true);
|
builder.show().setCanceledOnTouchOutside(true);
|
||||||
} else if (i == photoDownloadChatRow || i == photoDownloadPrivateRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow) {
|
} else if (i == photoDownloadChatRow || i == photoDownloadPrivateRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
LocaleController.getString("Enabled", R.string.Enabled),
|
LocaleController.getString("Enabled", R.string.Enabled),
|
||||||
@ -410,12 +402,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -449,11 +435,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (supportUser == null) {
|
if (supportUser == null) {
|
||||||
if (parentActivity == null) {
|
final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
|
||||||
return;
|
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
||||||
}
|
|
||||||
final ProgressDialog progressDialog = new ProgressDialog(parentActivity);
|
|
||||||
progressDialog.setMessage(parentActivity.getString(R.string.Loading));
|
|
||||||
progressDialog.setCanceledOnTouchOutside(false);
|
progressDialog.setCanceledOnTouchOutside(false);
|
||||||
progressDialog.setCancelable(false);
|
progressDialog.setCancelable(false);
|
||||||
progressDialog.show();
|
progressDialog.show();
|
||||||
@ -467,9 +450,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
Utilities.RunOnUIThread(new Runnable() {
|
Utilities.RunOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
editor.putInt("support_id", res.user.id);
|
editor.putInt("support_id", res.user.id);
|
||||||
SerializedData data = new SerializedData();
|
SerializedData data = new SerializedData();
|
||||||
@ -482,11 +462,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
MessagesController.getInstance().users.put(res.user.id, res.user);
|
MessagesController.getInstance().users.put(res.user.id, res.user);
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("user_id", res.user.id);
|
||||||
bundle.putInt("user_id", res.user.id);
|
presentFragment(new ChatActivity(args));
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -505,11 +483,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||||
} else {
|
} else {
|
||||||
MessagesController.getInstance().users.putIfAbsent(supportUser.id, supportUser);
|
MessagesController.getInstance().users.putIfAbsent(supportUser.id, supportUser);
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("user_id", supportUser.id);
|
||||||
bundle.putInt("user_id", supportUser.id);
|
presentFragment(new ChatActivity(args));
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,32 +520,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("Settings", R.string.Settings));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendLogs() {
|
private void sendLogs() {
|
||||||
try {
|
try {
|
||||||
ArrayList<Uri> uris = new ArrayList<Uri>();
|
ArrayList<Uri> uris = new ArrayList<Uri>();
|
||||||
@ -588,7 +538,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
i.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildVars.SEND_LOGS_EMAIL});
|
i.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildVars.SEND_LOGS_EMAIL});
|
||||||
i.putExtra(Intent.EXTRA_SUBJECT, "last logs");
|
i.putExtra(Intent.EXTRA_SUBJECT, "last logs");
|
||||||
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
|
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
|
||||||
startActivity(Intent.createChooser(i, "Select email application."));
|
getParentActivity().startActivity(Intent.createChooser(i, "Select email application."));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -596,30 +546,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
showActionBar();
|
||||||
if (isFinish) {
|
if (listAdapter != null) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ListAdapter extends BaseAdapter {
|
private class ListAdapter extends BaseAdapter {
|
||||||
@ -674,7 +604,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
((LaunchActivity)parentActivity).presentFragment(new SettingsChangeNameActivity(), "change_name", false);
|
presentFragment(new SettingsChangeNameActivity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -682,11 +612,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
button2.setOnClickListener(new View.OnClickListener() {
|
button2.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (parentActivity == null) {
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
|
||||||
|
|
||||||
CharSequence[] items;
|
CharSequence[] items;
|
||||||
|
|
||||||
@ -714,8 +640,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
||||||
NotificationCenter.getInstance().addToMemCache(56, user.id);
|
NotificationCenter.getInstance().addToMemCache(56, user.id);
|
||||||
NotificationCenter.getInstance().addToMemCache(53, user.photo.photo_big);
|
NotificationCenter.getInstance().addToMemCache(53, user.photo.photo_big);
|
||||||
Intent intent = new Intent(parentActivity, GalleryImageViewer.class);
|
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
} else if (i == 0 && !full || i == 1 && full) {
|
} else if (i == 0 && !full || i == 1 && full) {
|
||||||
avatarUpdater.openCamera();
|
avatarUpdater.openCamera();
|
||||||
@ -786,6 +712,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
if (user != null) {
|
if (user != null) {
|
||||||
textView.setText(Utilities.formatName(user.first_name, user.last_name));
|
textView.setText(Utilities.formatName(user.first_name, user.last_name));
|
||||||
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||||
|
avatarImage.processDetach = false;
|
||||||
TLRPC.FileLocation photo = null;
|
TLRPC.FileLocation photo = null;
|
||||||
if (user.photo != null) {
|
if (user.photo != null) {
|
||||||
photo = user.photo.photo_small;
|
photo = user.photo.photo_small;
|
||||||
@ -908,7 +835,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||||||
textView.setOnClickListener(new View.OnClickListener() {
|
textView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
|
@ -12,12 +12,7 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.internal.view.SupportMenuItem;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -36,8 +31,9 @@ import org.telegram.messenger.R;
|
|||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -69,16 +65,33 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
} else if (id == block_user) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("onlyUsers", true);
|
||||||
|
args.putBoolean("destroyAfterSelect", true);
|
||||||
|
args.putBoolean("usersAsSections", true);
|
||||||
|
args.putBoolean("returnAsResult", true);
|
||||||
|
ContactsActivity fragment = new ContactsActivity(args);
|
||||||
|
fragment.setDelegate(SettingsBlockedUsers.this);
|
||||||
|
presentFragment(fragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
|
menu.addItem(block_user, R.drawable.plus);
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.settings_blocked_users_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.settings_blocked_users_layout, container, false);
|
||||||
listViewAdapter = new ListAdapter(parentActivity);
|
listViewAdapter = new ListAdapter(getParentActivity());
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
progressView = fragmentView.findViewById(R.id.progressLayout);
|
progressView = fragmentView.findViewById(R.id.progressLayout);
|
||||||
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||||
@ -96,11 +109,9 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
if (i < blockedContacts.size()) {
|
if (i < blockedContacts.size()) {
|
||||||
UserProfileActivity fragment = new UserProfileActivity();
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("user_id", blockedContacts.get(i).user_id);
|
args.putInt("user_id", blockedContacts.get(i).user_id);
|
||||||
fragment.setArguments(args);
|
presentFragment(new UserProfileActivity(args));
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "user_" + blockedContacts.get(i).user_id, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -113,7 +124,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||||||
}
|
}
|
||||||
selectedUserId = blockedContacts.get(i).user_id;
|
selectedUserId = blockedContacts.get(i).user_id;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
|
||||||
CharSequence[] items = new CharSequence[] {LocaleController.getString("Unblock", R.string.Unblock)};
|
CharSequence[] items = new CharSequence[] {LocaleController.getString("Unblock", R.string.Unblock)};
|
||||||
|
|
||||||
@ -145,17 +156,6 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
emptyView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -250,76 +250,11 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).fixBackButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listViewAdapter != null) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listViewAdapter != null) {
|
|
||||||
listViewAdapter.notifyDataSetChanged();
|
listViewAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
SupportMenuItem item = (SupportMenuItem)menu.add(Menu.NONE, block_user, Menu.NONE, null).setIcon(R.drawable.plus);
|
|
||||||
item.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
case block_user:
|
|
||||||
ContactsActivity fragment = new ContactsActivity();
|
|
||||||
fragment.animationType = 1;
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean("onlyUsers", true);
|
|
||||||
bundle.putBoolean("destroyAfterSelect", true);
|
|
||||||
bundle.putBoolean("usersAsSections", true);
|
|
||||||
bundle.putBoolean("returnAsResult", true);
|
|
||||||
fragment.delegate = this;
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "contacts_block", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -400,7 +335,6 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||||||
view = li.inflate(R.layout.settings_unblock_info_row_layout, viewGroup, false);
|
view = li.inflate(R.layout.settings_unblock_info_row_layout, viewGroup, false);
|
||||||
TextView textView = (TextView)view.findViewById(R.id.info_text_view);
|
TextView textView = (TextView)view.findViewById(R.id.info_text_view);
|
||||||
textView.setText(LocaleController.getString("UnblockText", R.string.UnblockText));
|
textView.setText(LocaleController.getString("UnblockText", R.string.UnblockText));
|
||||||
registerForContextMenu(view);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
|
@ -10,14 +10,10 @@ package org.telegram.ui;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -33,7 +29,7 @@ import org.telegram.messenger.R;
|
|||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class SettingsChangeNameActivity extends BaseFragment {
|
public class SettingsChangeNameActivity extends BaseFragment {
|
||||||
private EditText firstNameField;
|
private EditText firstNameField;
|
||||||
@ -41,90 +37,32 @@ public class SettingsChangeNameActivity extends BaseFragment {
|
|||||||
private View headerLabelView;
|
private View headerLabelView;
|
||||||
private View doneButton;
|
private View doneButton;
|
||||||
|
|
||||||
public SettingsChangeNameActivity() {
|
|
||||||
animationType = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canApplyUpdateStatus() {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
return false;
|
if (fragmentView == null) {
|
||||||
}
|
actionBarLayer.setCustomView(R.layout.settings_do_action_layout);
|
||||||
|
Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button);
|
||||||
@Override
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onResume() {
|
@Override
|
||||||
super.onResume();
|
public void onClick(View view) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowCustomEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
|
|
||||||
actionBar.setCustomView(R.layout.settings_do_action_layout);
|
|
||||||
Button cancelButton = (Button)actionBar.getCustomView().findViewById(R.id.cancel_button);
|
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finishFragment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = actionBar.getCustomView().findViewById(R.id.done_button);
|
|
||||||
doneButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (firstNameField.getText().length() != 0) {
|
|
||||||
saveName();
|
|
||||||
finishFragment();
|
finishFragment();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
doneButton = actionBarLayer.findViewById(R.id.done_button);
|
||||||
|
doneButton.setOnClickListener(new View.OnClickListener() {
|
||||||
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
@Override
|
||||||
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
public void onClick(View view) {
|
||||||
textView.setText(LocaleController.getString("Done", R.string.Done));
|
if (firstNameField.getText().length() != 0) {
|
||||||
|
saveName();
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
finishFragment();
|
||||||
boolean animations = preferences.getBoolean("view_animations", true);
|
}
|
||||||
if (!animations) {
|
|
||||||
firstNameField.requestFocus();
|
|
||||||
Utilities.showKeyboard(firstNameField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
|
||||||
if (nextAnim != 0) {
|
|
||||||
Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
|
|
||||||
|
|
||||||
anim.setAnimationListener(new Animation.AnimationListener() {
|
|
||||||
|
|
||||||
public void onAnimationStart(Animation animation) {
|
|
||||||
SettingsChangeNameActivity.this.onAnimationStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationRepeat(Animation animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationEnd(Animation animation) {
|
|
||||||
SettingsChangeNameActivity.this.onAnimationEnd();
|
|
||||||
firstNameField.requestFocus();
|
|
||||||
Utilities.showKeyboard(firstNameField);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return anim;
|
cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel));
|
||||||
} else {
|
TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text);
|
||||||
return super.onCreateAnimation(transit, enter, nextAnim);
|
textView.setText(LocaleController.getString("Done", R.string.Done));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
|
||||||
fragmentView = inflater.inflate(R.layout.settings_change_name_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.settings_change_name_layout, container, false);
|
||||||
|
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId);
|
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId);
|
||||||
@ -175,6 +113,16 @@ public class SettingsChangeNameActivity extends BaseFragment {
|
|||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
|
boolean animations = preferences.getBoolean("view_animations", true);
|
||||||
|
if (!animations) {
|
||||||
|
firstNameField.requestFocus();
|
||||||
|
Utilities.showKeyboard(firstNameField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void saveName() {
|
private void saveName() {
|
||||||
TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile();
|
TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile();
|
||||||
if (UserConfig.currentUser == null || lastNameField.getText() == null || firstNameField.getText() == null) {
|
if (UserConfig.currentUser == null || lastNameField.getText() == null || firstNameField.getText() == null) {
|
||||||
@ -196,4 +144,10 @@ public class SettingsChangeNameActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpenAnimationEnd() {
|
||||||
|
firstNameField.requestFocus();
|
||||||
|
Utilities.showKeyboard(firstNameField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,8 @@ import android.content.SharedPreferences;
|
|||||||
import android.media.Ringtone;
|
import android.media.Ringtone;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -41,8 +37,8 @@ import org.telegram.messenger.MessagesController;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
public class SettingsNotificationsActivity extends BaseFragment {
|
public class SettingsNotificationsActivity extends BaseFragment {
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
@ -99,24 +95,26 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.settings_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.settings_layout, container, false);
|
||||||
ListAdapter listAdapter = new ListAdapter(parentActivity);
|
ListAdapter listAdapter = new ListAdapter(getParentActivity());
|
||||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (i == messageAlertRow || i == groupAlertRow) {
|
if (i == messageAlertRow || i == groupAlertRow) {
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
@ -192,7 +190,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||||
parentActivity.startActivityForResult(tmpIntent, i);
|
getParentActivity().startActivityForResult(tmpIntent, i);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
@ -209,20 +207,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MessagesController.getInstance().enableJoined = true;
|
MessagesController.getInstance().enableJoined = true;
|
||||||
ActionBarActivity inflaterActivity = parentActivity;
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
inflaterActivity = (ActionBarActivity)getActivity();
|
|
||||||
}
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reseting = false;
|
reseting = false;
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
editor.clear();
|
editor.clear();
|
||||||
editor.commit();
|
editor.commit();
|
||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
Toast toast = Toast.makeText(inflaterActivity, R.string.ResetNotificationsText, Toast.LENGTH_SHORT);
|
Toast toast = Toast.makeText(getParentActivity(), R.string.ResetNotificationsText, Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -274,7 +265,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
ApplicationLoader.startPushService();
|
ApplicationLoader.startPushService();
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo));
|
builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo));
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
@ -293,12 +284,6 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -313,13 +298,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||||
String name = null;
|
String name = null;
|
||||||
if (ringtone != null && parentActivity != null) {
|
if (ringtone != null) {
|
||||||
Ringtone rng = RingtoneManager.getRingtone(parentActivity, ringtone);
|
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
|
||||||
if (rng != null) {
|
if (rng != null) {
|
||||||
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||||
name = LocaleController.getString("Default", R.string.Default);
|
name = LocaleController.getString("Default", R.string.Default);
|
||||||
} else {
|
} else {
|
||||||
name = rng.getTitle(parentActivity);
|
name = rng.getTitle(getParentActivity());
|
||||||
}
|
}
|
||||||
rng.stop();
|
rng.stop();
|
||||||
}
|
}
|
||||||
@ -350,61 +335,6 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
|
||||||
super.onConfigurationChanged(newConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ListAdapter extends BaseAdapter {
|
private class ListAdapter extends BaseAdapter {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ import org.telegram.messenger.RPCRequest;
|
|||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.objects.PhotoObject;
|
import org.telegram.objects.PhotoObject;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.HorizontalListView;
|
import org.telegram.ui.Views.HorizontalListView;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -94,10 +94,10 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
|
||||||
listAdapter = new ListAdapter(parentActivity);
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
|
|
||||||
progressBar = (ProgressBar)fragmentView.findViewById(R.id.action_progress);
|
progressBar = (ProgressBar)fragmentView.findViewById(R.id.action_progress);
|
||||||
backgroundImage = (ImageView)fragmentView.findViewById(R.id.background_image);
|
backgroundImage = (ImageView)fragmentView.findViewById(R.id.background_image);
|
||||||
@ -107,16 +107,13 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
|
||||||
CharSequence[] items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("Cancel", R.string.Cancel)};
|
CharSequence[] items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("Cancel", R.string.Cancel)};
|
||||||
|
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
File image = Utilities.generatePicturePath();
|
File image = Utilities.generatePicturePath();
|
||||||
@ -124,11 +121,11 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
||||||
currentPicturePath = image.getAbsolutePath();
|
currentPicturePath = image.getAbsolutePath();
|
||||||
}
|
}
|
||||||
parentActivity.startActivityForResult(takePictureIntent, 10);
|
getParentActivity().startActivityForResult(takePictureIntent, 10);
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||||
photoPickerIntent.setType("image/*");
|
photoPickerIntent.setType("image/*");
|
||||||
parentActivity.startActivityForResult(photoPickerIntent, 11);
|
getParentActivity().startActivityForResult(photoPickerIntent, 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -404,52 +401,34 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fixLayout() {
|
private void fixLayout() {
|
||||||
final View view = getView();
|
ViewTreeObserver obs = fragmentView.getViewTreeObserver();
|
||||||
if (view != null) {
|
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
@Override
|
||||||
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
public boolean onPreDraw() {
|
||||||
@Override
|
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
public boolean onPreDraw() {
|
if (listAdapter != null) {
|
||||||
view.getViewTreeObserver().removeOnPreDrawListener(this);
|
listAdapter.notifyDataSetChanged();
|
||||||
if (listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
if (listView != null) {
|
|
||||||
listView.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
listView.scrollTo(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
if (listView != null) {
|
||||||
}
|
listView.post(new Runnable() {
|
||||||
}
|
@Override
|
||||||
|
public void run() {
|
||||||
@Override
|
listView.scrollTo(0);
|
||||||
public boolean canApplyUpdateStatus() {
|
}
|
||||||
return false;
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listAdapter != null) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
hideActionBar();
|
||||||
((LaunchActivity) parentActivity).hideActionBar();
|
|
||||||
|
|
||||||
processSelectedBackground();
|
processSelectedBackground();
|
||||||
|
|
||||||
fixLayout();
|
fixLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,15 +20,9 @@ import android.media.RingtoneManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
@ -48,10 +42,12 @@ import org.telegram.messenger.NotificationCenter;
|
|||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.RPCRequest;
|
import org.telegram.messenger.RPCRequest;
|
||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||||
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||||
import org.telegram.ui.Views.BackupImageView;
|
import org.telegram.ui.Views.BackupImageView;
|
||||||
import org.telegram.ui.Views.BaseFragment;
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
import org.telegram.ui.Views.IdenticonView;
|
import org.telegram.ui.Views.IdenticonView;
|
||||||
import org.telegram.ui.Views.OnSwipeTouchListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -84,21 +80,24 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
private int sharedMediaRow;
|
private int sharedMediaRow;
|
||||||
private int rowCount = 0;
|
private int rowCount = 0;
|
||||||
|
|
||||||
|
public UserProfileActivity(Bundle args) {
|
||||||
|
super(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.mediaCountDidLoaded);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.mediaCountDidLoaded);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatCreated);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatCreated);
|
||||||
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatUpdated);
|
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatUpdated);
|
||||||
user_id = getArguments().getInt("user_id", 0);
|
user_id = arguments.getInt("user_id", 0);
|
||||||
dialog_id = getArguments().getLong("dialog_id", 0);
|
dialog_id = arguments.getLong("dialog_id", 0);
|
||||||
if (dialog_id != 0) {
|
if (dialog_id != 0) {
|
||||||
currentEncryptedChat = MessagesController.getInstance().encryptedChats.get((int)(dialog_id >> 32));
|
currentEncryptedChat = MessagesController.getInstance().encryptedChats.get((int)(dialog_id >> 32));
|
||||||
}
|
}
|
||||||
updateRowsIds();
|
updateRowsIds();
|
||||||
return MessagesController.getInstance().users.get(user_id) != null;
|
return MessagesController.getInstance().users.get(user_id) != null && super.onFragmentCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -132,16 +131,78 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
if (fragmentView == null) {
|
if (fragmentView == null) {
|
||||||
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
||||||
|
if (dialog_id != 0) {
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
|
||||||
|
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
|
||||||
|
} else {
|
||||||
|
actionBarLayer.setTitle(LocaleController.getString("ContactInfo", R.string.ContactInfo));
|
||||||
|
}
|
||||||
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (id == -1) {
|
||||||
|
finishFragment();
|
||||||
|
} else if (id == block_contact) {
|
||||||
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TLRPC.TL_contacts_block req = new TLRPC.TL_contacts_block();
|
||||||
|
req.id = MessagesController.getInputUser(user);
|
||||||
|
TLRPC.TL_contactBlocked blocked = new TLRPC.TL_contactBlocked();
|
||||||
|
blocked.user_id = user_id;
|
||||||
|
blocked.date = (int)(System.currentTimeMillis() / 1000);
|
||||||
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
|
@Override
|
||||||
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||||
|
} else if (id == add_contact) {
|
||||||
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt("user_id", user.id);
|
||||||
|
presentFragment(new ContactAddActivity(args));
|
||||||
|
} else if (id == share_contact) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("onlySelect", true);
|
||||||
|
args.putBoolean("serverOnly", true);
|
||||||
|
MessagesActivity fragment = new MessagesActivity(args);
|
||||||
|
fragment.setDelegate(UserProfileActivity.this);
|
||||||
|
presentFragment(fragment);
|
||||||
|
} else if (id == edit_contact) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt("user_id", user_id);
|
||||||
|
presentFragment(new ContactAddActivity(args));
|
||||||
|
} else if (id == delete_contact) {
|
||||||
|
final TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
||||||
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
ArrayList<TLRPC.User> arrayList = new ArrayList<TLRPC.User>();
|
||||||
|
arrayList.add(user);
|
||||||
|
ContactsController.getInstance().deleteContact(arrayList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
|
builder.show().setCanceledOnTouchOutside(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
createActionBarMenu();
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.user_profile_layout, container, false);
|
fragmentView = inflater.inflate(R.layout.user_profile_layout, container, false);
|
||||||
listAdapter = new ListAdapter(parentActivity);
|
listAdapter = new ListAdapter(getParentActivity());
|
||||||
|
|
||||||
TextView textView = (TextView)fragmentView.findViewById(R.id.start_secret_button_text);
|
TextView textView = (TextView)fragmentView.findViewById(R.id.start_secret_button_text);
|
||||||
textView.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
textView.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
||||||
@ -151,7 +212,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
creatingChat = true;
|
creatingChat = true;
|
||||||
MessagesController.getInstance().startSecretChat(parentActivity, MessagesController.getInstance().users.get(user_id));
|
MessagesController.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().users.get(user_id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (dialog_id == 0) {
|
if (dialog_id == 0) {
|
||||||
@ -165,11 +226,8 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
LocaleController.getString("Default", R.string.Default),
|
LocaleController.getString("Default", R.string.Default),
|
||||||
@ -207,7 +265,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
||||||
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
Uri currentSound = null;
|
Uri currentSound = null;
|
||||||
|
|
||||||
String defaultPath = null;
|
String defaultPath = null;
|
||||||
@ -226,28 +284,24 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||||
parentActivity.startActivityForResult(tmpIntent, 12);
|
getParentActivity().startActivityForResult(tmpIntent, 12);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
} else if (i == sharedMediaRow) {
|
} else if (i == sharedMediaRow) {
|
||||||
MediaActivity fragment = new MediaActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
if (dialog_id != 0) {
|
if (dialog_id != 0) {
|
||||||
bundle.putLong("dialog_id", dialog_id);
|
args.putLong("dialog_id", dialog_id);
|
||||||
} else {
|
} else {
|
||||||
bundle.putLong("dialog_id", user_id);
|
args.putLong("dialog_id", user_id);
|
||||||
}
|
}
|
||||||
fragment.setArguments(bundle);
|
presentFragment(new MediaActivity(args));
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "media_user_" + user_id, false);
|
|
||||||
} else if (i == settingsKeyRow) {
|
} else if (i == settingsKeyRow) {
|
||||||
IdenticonActivity fragment = new IdenticonActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("chat_id", (int)(dialog_id >> 32));
|
||||||
bundle.putInt("chat_id", (int)(dialog_id >> 32));
|
presentFragment(new IdenticonActivity(args));
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "key_" + dialog_id, false);
|
|
||||||
} else if (i == settingsTimerRow) {
|
} else if (i == settingsTimerRow) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
builder.setTitle(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
||||||
builder.setItems(new CharSequence[]{
|
builder.setItems(new CharSequence[]{
|
||||||
LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever),
|
LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever),
|
||||||
@ -296,12 +350,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
} else {
|
} else {
|
||||||
MessagesController.getInstance().getMediaCount(user_id, classGuid, true);
|
MessagesController.getInstance().getMediaCount(user_id, classGuid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
listView.setOnTouchListener(new OnSwipeTouchListener() {
|
|
||||||
public void onSwipeRight() {
|
|
||||||
finishFragment(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -325,7 +373,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||||
name = LocaleController.getString("Default", R.string.Default);
|
name = LocaleController.getString("Default", R.string.Default);
|
||||||
} else {
|
} else {
|
||||||
name = rng.getTitle(parentActivity);
|
name = rng.getTitle(getParentActivity());
|
||||||
}
|
}
|
||||||
rng.stop();
|
rng.stop();
|
||||||
}
|
}
|
||||||
@ -357,9 +405,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (id == MessagesController.contactsDidLoaded) {
|
} else if (id == MessagesController.contactsDidLoaded) {
|
||||||
if (parentActivity != null) {
|
createActionBarMenu();
|
||||||
parentActivity.supportInvalidateOptionsMenu();
|
|
||||||
}
|
|
||||||
} else if (id == MessagesController.mediaCountDidLoaded) {
|
} else if (id == MessagesController.mediaCountDidLoaded) {
|
||||||
long uid = (Long)args[0];
|
long uid = (Long)args[0];
|
||||||
if (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) {
|
if (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) {
|
||||||
@ -372,11 +418,9 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if (creatingChat) {
|
if (creatingChat) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
|
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args2 = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args2.putInt("enc_id", encryptedChat.id);
|
||||||
bundle.putInt("enc_id", encryptedChat.id);
|
presentFragment(new ChatActivity(args2), true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
}
|
}
|
||||||
} else if (id == MessagesController.encryptedChatUpdated) {
|
} else if (id == MessagesController.encryptedChatUpdated) {
|
||||||
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)args[0];
|
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)args[0];
|
||||||
@ -390,220 +434,57 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ActionBar actionBar = parentActivity.getSupportActionBar();
|
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
actionBar.setSubtitle(null);
|
|
||||||
actionBar.setDisplayShowHomeEnabled(false);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
actionBar.setDisplayUseLogoEnabled(false);
|
|
||||||
actionBar.setDisplayShowCustomEnabled(false);
|
|
||||||
actionBar.setCustomView(null);
|
|
||||||
if (dialog_id != 0) {
|
|
||||||
actionBar.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
|
|
||||||
} else {
|
|
||||||
actionBar.setTitle(LocaleController.getString("ContactInfo", R.string.ContactInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
if (dialog_id != 0) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(Utilities.dp(4));
|
|
||||||
} else {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
if (listAdapter != null) {
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!firstStart && listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
firstStart = false;
|
|
||||||
((LaunchActivity)parentActivity).showActionBar();
|
|
||||||
((LaunchActivity)parentActivity).updateActionBar();
|
|
||||||
fixLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void createActionBarMenu() {
|
||||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||||
super.onConfigurationChanged(newConfig);
|
menu.clearItems();
|
||||||
fixLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fixLayout() {
|
|
||||||
if (listView != null) {
|
|
||||||
ViewTreeObserver obs = listView.getViewTreeObserver();
|
|
||||||
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreDraw() {
|
|
||||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
||||||
if (dialog_id != 0) {
|
|
||||||
TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title);
|
|
||||||
if (title == null) {
|
|
||||||
final int subtitleId = ApplicationLoader.applicationContext.getResources().getIdentifier("action_bar_title", "id", "android");
|
|
||||||
title = (TextView)parentActivity.findViewById(subtitleId);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
|
|
||||||
title.setCompoundDrawablePadding(Utilities.dp(4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case android.R.id.home:
|
|
||||||
finishFragment();
|
|
||||||
break;
|
|
||||||
case block_contact: {
|
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
||||||
if (user == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
TLRPC.TL_contacts_block req = new TLRPC.TL_contacts_block();
|
|
||||||
req.id = MessagesController.getInputUser(user);
|
|
||||||
TLRPC.TL_contactBlocked blocked = new TLRPC.TL_contactBlocked();
|
|
||||||
blocked.user_id = user_id;
|
|
||||||
blocked.date = (int)(System.currentTimeMillis() / 1000);
|
|
||||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
|
||||||
@Override
|
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case add_contact: {
|
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
||||||
ContactAddActivity fragment = new ContactAddActivity();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putInt("user_id", user.id);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "add_contact_" + user.id, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case share_contact: {
|
|
||||||
MessagesActivity fragment = new MessagesActivity();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putBoolean("onlySelect", true);
|
|
||||||
args.putBoolean("serverOnly", true);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
fragment.delegate = this;
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat_select", false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case edit_contact: {
|
|
||||||
ContactAddActivity fragment = new ContactAddActivity();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putInt("user_id", user_id);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "add_contact_" + user_id, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case delete_contact: {
|
|
||||||
final TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
||||||
if (user == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
|
||||||
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
||||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
ArrayList<TLRPC.User> arrayList = new ArrayList<TLRPC.User>();
|
|
||||||
arrayList.add(user);
|
|
||||||
ContactsController.getInstance().deleteContact(arrayList);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
||||||
builder.show().setCanceledOnTouchOutside(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
if (ContactsController.getInstance().contactsDict.get(user_id) == null) {
|
if (ContactsController.getInstance().contactsDict.get(user_id) == null) {
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
||||||
if (user.phone != null && user.phone.length() != 0) {
|
if (user.phone != null && user.phone.length() != 0) {
|
||||||
menu.add(Menu.NONE, add_contact, Menu.NONE, LocaleController.getString("AddContact", R.string.AddContact));
|
item.addSubItem(add_contact, LocaleController.getString("AddContact", R.string.AddContact), 0);
|
||||||
menu.add(Menu.NONE, block_contact, Menu.NONE, LocaleController.getString("BlockContact", R.string.BlockContact));
|
item.addSubItem(block_contact, LocaleController.getString("BlockContact", R.string.BlockContact), 0);
|
||||||
} else {
|
} else {
|
||||||
menu.add(Menu.NONE, block_contact, Menu.NONE, LocaleController.getString("BlockContact", R.string.BlockContact));
|
item.addSubItem(block_contact, LocaleController.getString("BlockContact", R.string.BlockContact), 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
menu.add(Menu.NONE, share_contact, Menu.NONE, LocaleController.getString("ShareContact", R.string.ShareContact));
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
||||||
menu.add(Menu.NONE, block_contact, Menu.NONE, LocaleController.getString("BlockContact", R.string.BlockContact));
|
item.addSubItem(share_contact, LocaleController.getString("ShareContact", R.string.ShareContact), 0);
|
||||||
menu.add(Menu.NONE, edit_contact, Menu.NONE, LocaleController.getString("EditContact", R.string.EditContact));
|
item.addSubItem(block_contact, LocaleController.getString("BlockContact", R.string.BlockContact), 0);
|
||||||
menu.add(Menu.NONE, delete_contact, Menu.NONE, LocaleController.getString("DeleteContact", R.string.DeleteContact));
|
item.addSubItem(edit_contact, LocaleController.getString("EditContact", R.string.EditContact), 0);
|
||||||
|
item.addSubItem(delete_contact, LocaleController.getString("DeleteContact", R.string.DeleteContact), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id) {
|
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id) {
|
||||||
if (dialog_id != 0) {
|
if (dialog_id != 0) {
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putBoolean("scrollToTopOnResume", true);
|
||||||
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
int lower_part = (int)dialog_id;
|
int lower_part = (int)dialog_id;
|
||||||
if (lower_part != 0) {
|
if (lower_part != 0) {
|
||||||
if (lower_part > 0) {
|
if (lower_part > 0) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
args.putInt("user_id", lower_part);
|
||||||
bundle.putInt("user_id", lower_part);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
fragment.scrollToTopOnResume = true;
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
removeSelfFromStack();
|
|
||||||
messageFragment.removeSelfFromStack();
|
|
||||||
} else if (lower_part < 0) {
|
} else if (lower_part < 0) {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
args.putInt("chat_id", -lower_part);
|
||||||
bundle.putInt("chat_id", -lower_part);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
fragment.scrollToTopOnResume = true;
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
messageFragment.removeSelfFromStack();
|
|
||||||
removeSelfFromStack();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
args.putInt("enc_id", (int)(dialog_id >> 32));
|
||||||
int id = (int)(dialog_id >> 32);
|
|
||||||
bundle.putInt("enc_id", id);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
fragment.scrollToTopOnResume = true;
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
|
|
||||||
messageFragment.removeSelfFromStack();
|
|
||||||
removeSelfFromStack();
|
|
||||||
}
|
}
|
||||||
|
presentFragment(new ChatActivity(args), true);
|
||||||
|
messageFragment.removeSelfFromStack();
|
||||||
|
removeSelfFromStack();
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
MessagesController.getInstance().sendMessage(user, dialog_id);
|
MessagesController.getInstance().sendMessage(user, dialog_id);
|
||||||
}
|
}
|
||||||
@ -659,6 +540,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
|
|
||||||
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
||||||
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||||
|
avatarImage.processDetach = false;
|
||||||
avatarImage.setOnClickListener(new View.OnClickListener() {
|
avatarImage.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -666,8 +548,8 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
if (user.photo != null && user.photo.photo_big != null) {
|
if (user.photo != null && user.photo.photo_big != null) {
|
||||||
NotificationCenter.getInstance().addToMemCache(56, user_id);
|
NotificationCenter.getInstance().addToMemCache(56, user_id);
|
||||||
NotificationCenter.getInstance().addToMemCache(53, user.photo.photo_big);
|
NotificationCenter.getInstance().addToMemCache(53, user.photo.photo_big);
|
||||||
Intent intent = new Intent(parentActivity, GalleryImageViewer.class);
|
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -714,7 +596,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
}
|
}
|
||||||
selectedPhone = user.phone;
|
selectedPhone = user.phone;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
|
||||||
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
|
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -723,24 +605,17 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
try {
|
try {
|
||||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + selectedPhone));
|
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + selectedPhone));
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
getParentActivity().startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
} else if (i == 0) {
|
} else if (i == 0) {
|
||||||
ActionBarActivity inflaterActivity = parentActivity;
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
inflaterActivity = (ActionBarActivity)getActivity();
|
|
||||||
}
|
|
||||||
if (inflaterActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int sdk = android.os.Build.VERSION.SDK_INT;
|
int sdk = android.os.Build.VERSION.SDK_INT;
|
||||||
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)inflaterActivity.getSystemService(Context.CLIPBOARD_SERVICE);
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
clipboard.setText(selectedPhone);
|
clipboard.setText(selectedPhone);
|
||||||
} else {
|
} else {
|
||||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)inflaterActivity.getSystemService(Context.CLIPBOARD_SERVICE);
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
android.content.ClipData clip = android.content.ClipData.newPlainText("label", selectedPhone);
|
android.content.ClipData clip = android.content.ClipData.newPlainText("label", selectedPhone);
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
}
|
}
|
||||||
@ -755,19 +630,14 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (parentActivity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||||
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||||
ChatActivity fragment = new ChatActivity();
|
Bundle args = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
args.putInt("user_id", user_id);
|
||||||
bundle.putInt("user_id", user_id);
|
presentFragment(new ChatActivity(args), true);
|
||||||
fragment.setArguments(bundle);
|
|
||||||
((LaunchActivity)parentActivity).presentFragment(fragment, "chat" + Math.random(), true, false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||||
|
@ -0,0 +1,208 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.4.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Views.ActionBar;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.Utilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ActionBar extends FrameLayout {
|
||||||
|
|
||||||
|
private static Drawable logoDrawable;
|
||||||
|
protected ActionBarLayer currentLayer = null;
|
||||||
|
private ActionBarLayer previousLayer = null;
|
||||||
|
private View currentBackOverlay;
|
||||||
|
private View shadowView = null;
|
||||||
|
private int currentBackOverlayWidth;
|
||||||
|
|
||||||
|
public ActionBar(Context context) {
|
||||||
|
super(context);
|
||||||
|
createComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBar(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
createComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
createComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createComponents() {
|
||||||
|
shadowView = new View(getContext());
|
||||||
|
addView(shadowView);
|
||||||
|
shadowView.setVisibility(INVISIBLE);
|
||||||
|
ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams();
|
||||||
|
layoutParams.width = Utilities.dp(2);
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
shadowView.setLayoutParams(layoutParams);
|
||||||
|
shadowView.setBackgroundResource(R.drawable.shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarLayer createLayer() {
|
||||||
|
return new ActionBarLayer(getContext(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void detachActionBarLayer(ActionBarLayer layer) {
|
||||||
|
if (layer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
removeView(layer);
|
||||||
|
if (currentLayer == layer) {
|
||||||
|
currentLayer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentActionBarLayer(ActionBarLayer layer) {
|
||||||
|
if (layer == null || layer.getParent() != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (currentLayer != null) {
|
||||||
|
removeView(currentLayer);
|
||||||
|
}
|
||||||
|
currentLayer = layer;
|
||||||
|
addView(layer);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)layer.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
layer.setLayoutParams(layoutParams);
|
||||||
|
updateBackOverlay(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
||||||
|
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||||
|
layer.setAlpha(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackOverlay(View view, int width) {
|
||||||
|
if (currentBackOverlay != null) {
|
||||||
|
removeView(currentBackOverlay);
|
||||||
|
}
|
||||||
|
if (view != null) {
|
||||||
|
addView(view);
|
||||||
|
}
|
||||||
|
currentBackOverlayWidth = width;
|
||||||
|
currentBackOverlay = view;
|
||||||
|
updateBackOverlay(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBackOverlay(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
if (currentLayer != null) {
|
||||||
|
currentLayer.setBackLayoutVisible(currentBackOverlay == null ? VISIBLE : INVISIBLE);
|
||||||
|
}
|
||||||
|
if (currentBackOverlay != null) {
|
||||||
|
ViewGroup.LayoutParams layoutParams = currentBackOverlay.getLayoutParams();
|
||||||
|
if (currentLayer != null) {
|
||||||
|
currentLayer.measure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
layoutParams.width = Math.min(currentBackOverlayWidth, currentLayer.getBackLayoutWidth());
|
||||||
|
} else {
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
}
|
||||||
|
if (layoutParams.width != 0) {
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
currentBackOverlay.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void prepareForMoving(ActionBarLayer layer) {
|
||||||
|
if (currentLayer == null || layer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
previousLayer = layer;
|
||||||
|
ViewGroup parent = (ViewGroup) previousLayer.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(previousLayer);
|
||||||
|
}
|
||||||
|
this.addView(previousLayer, 0);
|
||||||
|
ViewGroup.LayoutParams layoutParams = layer.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
layer.setLayoutParams(layoutParams);
|
||||||
|
currentLayer.setBackgroundDrawable(getBackground());
|
||||||
|
shadowView.setX(-Utilities.dp(2));
|
||||||
|
shadowView.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopMoving(boolean backAnimation) {
|
||||||
|
if (currentLayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentLayer.setBackgroundDrawable(null);
|
||||||
|
currentLayer.setX(0);
|
||||||
|
if (!backAnimation) {
|
||||||
|
removeView(currentLayer);
|
||||||
|
currentLayer = previousLayer;
|
||||||
|
currentLayer.setAlpha(1);
|
||||||
|
} else {
|
||||||
|
removeView(previousLayer);
|
||||||
|
previousLayer = null;
|
||||||
|
}
|
||||||
|
shadowView.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveActionBarByX(int dx) {
|
||||||
|
if (currentLayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentLayer.setX(dx);
|
||||||
|
shadowView.setX(dx - Utilities.dp(2));
|
||||||
|
if (dx != 0) {
|
||||||
|
if (previousLayer != null) {
|
||||||
|
previousLayer.setAlpha(Math.min(1, (float) dx / (float) currentLayer.getMeasuredWidth()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (previousLayer != null) {
|
||||||
|
previousLayer.setAlpha(0);
|
||||||
|
}
|
||||||
|
currentLayer.setAlpha(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupAnimations(ArrayList<Animator> animators, boolean back) {
|
||||||
|
if (back) {
|
||||||
|
animators.add(ObjectAnimator.ofFloat(currentLayer, "x", 0));
|
||||||
|
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -Utilities.dp(2)));
|
||||||
|
animators.add(ObjectAnimator.ofFloat(previousLayer, "alpha", 0));
|
||||||
|
} else {
|
||||||
|
animators.add(ObjectAnimator.ofFloat(currentLayer, "x", getMeasuredWidth()));
|
||||||
|
animators.add(ObjectAnimator.ofFloat(shadowView, "x", getMeasuredWidth() - Utilities.dp(2)));
|
||||||
|
animators.add(ObjectAnimator.ofFloat(previousLayer, "alpha", 1.0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
updateBackOverlay(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Utilities.dp(40), MeasureSpec.EXACTLY));
|
||||||
|
} else {
|
||||||
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Utilities.dp(48), MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMenuButtonPressed() {
|
||||||
|
if (currentLayer != null) {
|
||||||
|
currentLayer.onMenuButtonPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,623 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.4.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Views.ActionBar;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.ActionMode;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.Surface;
|
||||||
|
import android.view.VelocityTracker;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import org.telegram.messenger.FileLog;
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.Utilities;
|
||||||
|
import org.telegram.ui.ChatActivity;
|
||||||
|
import org.telegram.ui.GroupCreateFinalActivity;
|
||||||
|
import org.telegram.ui.SettingsActivity;
|
||||||
|
import org.telegram.ui.SettingsWallpapersActivity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ActionBarActivity extends Activity {
|
||||||
|
|
||||||
|
protected ActionBar actionBar;
|
||||||
|
private FrameLayout containerView;
|
||||||
|
private FrameLayout containerViewBack;
|
||||||
|
private FrameLayout contentView;
|
||||||
|
private View shadowView;
|
||||||
|
|
||||||
|
private Animation openAnimation;
|
||||||
|
private Animation closeAnimation;
|
||||||
|
|
||||||
|
private boolean startedTracking = false;
|
||||||
|
private int startedTrackingX;
|
||||||
|
private int prevOrientation = -10;
|
||||||
|
private boolean animationInProgress = false;
|
||||||
|
private VelocityTracker velocityTracker = null;
|
||||||
|
private boolean beginTrackingSent = false;
|
||||||
|
private boolean transitionAnimationInProgress = false;
|
||||||
|
private long transitionAnimationStartTime;
|
||||||
|
private boolean inActionMode = false;
|
||||||
|
|
||||||
|
public static ArrayList<BaseFragment> fragmentsStack = new ArrayList<BaseFragment>();
|
||||||
|
|
||||||
|
protected void onCreateFinish(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
try {
|
||||||
|
openAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_in);
|
||||||
|
closeAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_out);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTheme(R.style.Theme_TMessages);
|
||||||
|
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
||||||
|
|
||||||
|
contentView = new FrameLayout(this);
|
||||||
|
setContentView(contentView, new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
|
containerViewBack = new FrameLayout(this);
|
||||||
|
contentView.addView(containerViewBack);
|
||||||
|
|
||||||
|
containerView = new FrameLayout(this);
|
||||||
|
contentView.addView(containerView);
|
||||||
|
|
||||||
|
shadowView = new FrameLayout(this);
|
||||||
|
contentView.addView(shadowView);
|
||||||
|
shadowView.setBackgroundResource(R.drawable.shadow);
|
||||||
|
ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams();
|
||||||
|
layoutParams.width = Utilities.dp(2);
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
shadowView.setLayoutParams(layoutParams);
|
||||||
|
shadowView.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
actionBar = new ActionBar(this);
|
||||||
|
actionBar.setBackgroundResource(R.color.header);
|
||||||
|
contentView.addView(actionBar);
|
||||||
|
layoutParams = actionBar.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
actionBar.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
for (BaseFragment fragment : fragmentsStack) {
|
||||||
|
fragment.setParentActivity(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
needLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
fixLayout();
|
||||||
|
if (!fragmentsStack.isEmpty()) {
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
lastFragment.onConfigurationChanged(newConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
fixLayout();
|
||||||
|
if (!fragmentsStack.isEmpty()) {
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
lastFragment.onResume();
|
||||||
|
|
||||||
|
actionBar.setCurrentActionBarLayer(lastFragment.actionBarLayer);
|
||||||
|
onShowFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (!fragmentsStack.isEmpty()) {
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
lastFragment.onPause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSlideAnimationEnd(boolean backAnimation) {
|
||||||
|
containerView.setX(0);
|
||||||
|
containerViewBack.setX(0);
|
||||||
|
actionBar.stopMoving(backAnimation);
|
||||||
|
shadowView.setVisibility(View.INVISIBLE);
|
||||||
|
shadowView.setX(-Utilities.dp(2));
|
||||||
|
if (!backAnimation) {
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
lastFragment.onPause();
|
||||||
|
lastFragment.onFragmentDestroy();
|
||||||
|
lastFragment.setParentActivity(null);
|
||||||
|
fragmentsStack.remove(fragmentsStack.size() - 1);
|
||||||
|
|
||||||
|
FrameLayout temp = containerView;
|
||||||
|
containerView = containerViewBack;
|
||||||
|
containerViewBack = temp;
|
||||||
|
ViewGroup parent = (ViewGroup)containerView.getParent();
|
||||||
|
parent.removeView(containerView);
|
||||||
|
parent.addView(containerView, 1);
|
||||||
|
lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
lastFragment.onResume();
|
||||||
|
} else {
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
|
||||||
|
lastFragment.onPause();
|
||||||
|
if (lastFragment.fragmentView != null) {
|
||||||
|
ViewGroup parent = (ViewGroup) lastFragment.fragmentView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(lastFragment.fragmentView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
containerViewBack.setVisibility(View.GONE);
|
||||||
|
try {
|
||||||
|
if (prevOrientation != -10) {
|
||||||
|
setRequestedOrientation(prevOrientation);
|
||||||
|
prevOrientation = -10;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
startedTracking = false;
|
||||||
|
animationInProgress = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||||
|
if(android.os.Build.VERSION.SDK_INT >= 11 && !checkTransitionAnimation() && !inActionMode) {
|
||||||
|
if (ev.getAction() == MotionEvent.ACTION_DOWN && !startedTracking && ev.getX() <= Utilities.dp(6) && fragmentsStack.size() > 1) {
|
||||||
|
startedTracking = true;
|
||||||
|
startedTrackingX = (int) ev.getX();
|
||||||
|
shadowView.setVisibility(View.VISIBLE);
|
||||||
|
shadowView.setX(-Utilities.dp(2));
|
||||||
|
containerViewBack.setVisibility(View.VISIBLE);
|
||||||
|
beginTrackingSent = false;
|
||||||
|
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
|
||||||
|
actionBar.prepareForMoving(lastFragment.actionBarLayer);
|
||||||
|
View fragmentView = lastFragment.createView(getLayoutInflater(), null);
|
||||||
|
ViewGroup parentView = (ViewGroup)fragmentView.getParent();
|
||||||
|
if (parentView != null) {
|
||||||
|
parentView.removeView(fragmentView);
|
||||||
|
}
|
||||||
|
containerViewBack.addView(fragmentView);
|
||||||
|
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
fragmentView.setLayoutParams(layoutParams);
|
||||||
|
if (fragmentView.getBackground() == null) {
|
||||||
|
fragmentView.setBackgroundColor(0xffffffff);
|
||||||
|
}
|
||||||
|
lastFragment.onResume();
|
||||||
|
|
||||||
|
try {
|
||||||
|
prevOrientation = getRequestedOrientation();
|
||||||
|
WindowManager manager = (WindowManager)getSystemService(Activity.WINDOW_SERVICE);
|
||||||
|
if (manager != null && manager.getDefaultDisplay() != null) {
|
||||||
|
int rotation = manager.getDefaultDisplay().getRotation();
|
||||||
|
if (rotation == Surface.ROTATION_270) {
|
||||||
|
if (Build.VERSION.SDK_INT >= 9) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||||
|
} else {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
}
|
||||||
|
} else if (rotation == Surface.ROTATION_90) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
} else if (rotation == Surface.ROTATION_0) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
} else {
|
||||||
|
if (Build.VERSION.SDK_INT >= 9) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
if (velocityTracker == null) {
|
||||||
|
velocityTracker = VelocityTracker.obtain();
|
||||||
|
} else {
|
||||||
|
velocityTracker.clear();
|
||||||
|
}
|
||||||
|
} else if (startedTracking && !animationInProgress) {
|
||||||
|
if (ev.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
|
if (!beginTrackingSent) {
|
||||||
|
if (getCurrentFocus() != null) {
|
||||||
|
Utilities.hideKeyboard(getCurrentFocus());
|
||||||
|
}
|
||||||
|
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
currentFragment.onBeginSlide();
|
||||||
|
beginTrackingSent = true;
|
||||||
|
}
|
||||||
|
velocityTracker.addMovement(ev);
|
||||||
|
int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
|
||||||
|
actionBar.moveActionBarByX(dx);
|
||||||
|
containerView.setX(dx);
|
||||||
|
shadowView.setX(dx - Utilities.dp(2));
|
||||||
|
} else if (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
velocityTracker.computeCurrentVelocity(1000);
|
||||||
|
float x = containerView.getX();
|
||||||
|
ArrayList<Animator> animators = new ArrayList<Animator>();
|
||||||
|
final boolean backAnimation = x < containerView.getMeasuredWidth() / 3.0f && velocityTracker.getXVelocity() < 6000;
|
||||||
|
float distToMove = 0;
|
||||||
|
if (!backAnimation) {
|
||||||
|
distToMove = containerView.getMeasuredWidth() - x;
|
||||||
|
animators.add(ObjectAnimator.ofFloat(containerView, "x", containerView.getMeasuredWidth()));
|
||||||
|
animators.add(ObjectAnimator.ofFloat(shadowView, "x", containerView.getMeasuredWidth() - Utilities.dp(2)));
|
||||||
|
} else {
|
||||||
|
distToMove = x;
|
||||||
|
animators.add(ObjectAnimator.ofFloat(containerView, "x", 0));
|
||||||
|
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -Utilities.dp(2)));
|
||||||
|
}
|
||||||
|
actionBar.setupAnimations(animators, backAnimation);
|
||||||
|
|
||||||
|
AnimatorSet animatorSet = new AnimatorSet();
|
||||||
|
animatorSet.playTogether(animators);
|
||||||
|
animatorSet.setDuration((int)(200.0f / containerView.getMeasuredWidth() * distToMove));
|
||||||
|
animatorSet.start();
|
||||||
|
animationInProgress = true;
|
||||||
|
animatorSet.addListener(new Animator.AnimatorListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animator animator) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animator) {
|
||||||
|
onSlideAnimationEnd(backAnimation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animator) {
|
||||||
|
onSlideAnimationEnd(backAnimation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animator animator) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
velocityTracker.recycle();
|
||||||
|
velocityTracker = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return startedTracking || super.dispatchTouchEvent(ev);
|
||||||
|
}
|
||||||
|
return super.dispatchTouchEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (startedTracking || checkTransitionAnimation()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (actionBar.currentLayer != null && actionBar.currentLayer.isSearchFieldVisible) {
|
||||||
|
actionBar.currentLayer.closeSearchField();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
if (lastFragment.onBackPressed()) {
|
||||||
|
if (fragmentsStack.size() == 1) {
|
||||||
|
fragmentsStack.get(0).onFragmentDestroy();
|
||||||
|
fragmentsStack.clear();
|
||||||
|
onFinish();
|
||||||
|
finish();
|
||||||
|
} else if (!fragmentsStack.isEmpty()) {
|
||||||
|
closeLastFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {
|
||||||
|
super.onLowMemory();
|
||||||
|
for (BaseFragment fragment : fragmentsStack) {
|
||||||
|
fragment.onLowMemory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkTransitionAnimation() {
|
||||||
|
if (transitionAnimationInProgress && transitionAnimationStartTime < System.currentTimeMillis() - 400) {
|
||||||
|
transitionAnimationInProgress = false;
|
||||||
|
}
|
||||||
|
return transitionAnimationInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixLayout() {
|
||||||
|
if (contentView != null) {
|
||||||
|
ViewTreeObserver obs = contentView.getViewTreeObserver();
|
||||||
|
obs.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
needLayout();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < 16) {
|
||||||
|
contentView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void needLayout() {
|
||||||
|
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
|
int rotation = manager.getDefaultDisplay().getRotation();
|
||||||
|
|
||||||
|
int height = 0;
|
||||||
|
if (actionBar.getVisibility() == View.VISIBLE) {
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
height = Utilities.dp(40);
|
||||||
|
} else {
|
||||||
|
height = Utilities.dp(48);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containerView != null) {
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
|
||||||
|
if (layoutParams.topMargin != height) {
|
||||||
|
layoutParams.setMargins(0, height, 0, 0);
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
containerView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (containerViewBack != null) {
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams();
|
||||||
|
if (layoutParams.topMargin != height) {
|
||||||
|
layoutParams.setMargins(0, height, 0, 0);
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
containerViewBack.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBar getInternalActionBar() {
|
||||||
|
return actionBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void presentFragmentInternalRemoveOld(boolean removeLast, BaseFragment fragment) {
|
||||||
|
if (fragment == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fragment.onPause();
|
||||||
|
if (removeLast) {
|
||||||
|
fragment.onFragmentDestroy();
|
||||||
|
fragment.setParentActivity(null);
|
||||||
|
fragmentsStack.remove(fragment);
|
||||||
|
} else {
|
||||||
|
if (fragment.fragmentView != null) {
|
||||||
|
ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(fragment.fragmentView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean presentFragment(BaseFragment fragment) {
|
||||||
|
return presentFragment(fragment, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean presentFragment(BaseFragment fragment, boolean removeLast) {
|
||||||
|
return presentFragment(fragment, removeLast, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation) {
|
||||||
|
if (!fragment.onFragmentCreate() || checkTransitionAnimation()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getCurrentFocus() != null) {
|
||||||
|
Utilities.hideKeyboard(getCurrentFocus());
|
||||||
|
}
|
||||||
|
boolean needAnimation = openAnimation != null && !forceWithoutAnimation && getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true);
|
||||||
|
|
||||||
|
final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;
|
||||||
|
if (!needAnimation) {
|
||||||
|
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment.setParentActivity(this);
|
||||||
|
View fragmentView = fragment.createView(getLayoutInflater(), null);
|
||||||
|
containerView.addView(fragmentView);
|
||||||
|
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
fragmentView.setLayoutParams(layoutParams);
|
||||||
|
fragmentsStack.add(fragment);
|
||||||
|
fragment.onResume();
|
||||||
|
actionBar.setCurrentActionBarLayer(fragment.actionBarLayer);
|
||||||
|
if (fragmentView.getBackground() == null) {
|
||||||
|
fragmentView.setBackgroundColor(0xffffffff);
|
||||||
|
}
|
||||||
|
onShowFragment();
|
||||||
|
if (needAnimation) {
|
||||||
|
transitionAnimationStartTime = System.currentTimeMillis();
|
||||||
|
transitionAnimationInProgress = true;
|
||||||
|
openAnimation.reset();
|
||||||
|
openAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
transitionAnimationInProgress = false;
|
||||||
|
transitionAnimationStartTime = 0;
|
||||||
|
fragment.onOpenAnimationEnd();
|
||||||
|
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fragmentView.startAnimation(openAnimation);
|
||||||
|
} else {
|
||||||
|
fragment.onOpenAnimationEnd();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeLastFragmentInternalRemoveOld(BaseFragment fragment) {
|
||||||
|
fragment.onPause();
|
||||||
|
fragment.onFragmentDestroy();
|
||||||
|
fragment.setParentActivity(null);
|
||||||
|
fragmentsStack.remove(fragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeLastFragment() {
|
||||||
|
if (fragmentsStack.size() <= 1 || checkTransitionAnimation()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (getCurrentFocus() != null) {
|
||||||
|
Utilities.hideKeyboard(getCurrentFocus());
|
||||||
|
}
|
||||||
|
boolean needAnimation = openAnimation != null && getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true);
|
||||||
|
final BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 2);
|
||||||
|
if (!needAnimation) {
|
||||||
|
closeLastFragmentInternalRemoveOld(currentFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
previousFragment.setParentActivity(this);
|
||||||
|
View fragmentView = previousFragment.createView(getLayoutInflater(), null);
|
||||||
|
containerView.addView(fragmentView, 0);
|
||||||
|
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
fragmentView.setLayoutParams(layoutParams);
|
||||||
|
previousFragment.onResume();
|
||||||
|
actionBar.setCurrentActionBarLayer(previousFragment.actionBarLayer);
|
||||||
|
if (fragmentView.getBackground() == null) {
|
||||||
|
fragmentView.setBackgroundColor(0xffffffff);
|
||||||
|
}
|
||||||
|
onShowFragment();
|
||||||
|
if (needAnimation) {
|
||||||
|
transitionAnimationStartTime = System.currentTimeMillis();
|
||||||
|
transitionAnimationInProgress = true;
|
||||||
|
closeAnimation.reset();
|
||||||
|
closeAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
transitionAnimationInProgress = false;
|
||||||
|
transitionAnimationStartTime = 0;
|
||||||
|
closeLastFragmentInternalRemoveOld(currentFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
currentFragment.fragmentView.startAnimation(closeAnimation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showLastFragment() {
|
||||||
|
BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||||
|
previousFragment.setParentActivity(this);
|
||||||
|
View fragmentView = previousFragment.createView(getLayoutInflater(), null);
|
||||||
|
containerView.addView(fragmentView);
|
||||||
|
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||||
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
fragmentView.setLayoutParams(layoutParams);
|
||||||
|
previousFragment.onResume();
|
||||||
|
actionBar.setCurrentActionBarLayer(previousFragment.actionBarLayer);
|
||||||
|
if (fragmentView.getBackground() == null) {
|
||||||
|
fragmentView.setBackgroundColor(0xffffffff);
|
||||||
|
}
|
||||||
|
onShowFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFragmentFromStack(BaseFragment fragment) {
|
||||||
|
// if (!fragmentsStack.isEmpty() && fragmentsStack.get(fragmentsStack.size() - 1) == fragment) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
fragment.onFragmentDestroy();
|
||||||
|
fragment.setParentActivity(null);
|
||||||
|
fragmentsStack.remove(fragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rebuildAllFragmentViews() {
|
||||||
|
for (int a = 0; a < fragmentsStack.size() - 1; a++) {
|
||||||
|
fragmentsStack.get(a).setParentActivity(null);
|
||||||
|
fragmentsStack.get(a).setParentActivity(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onFinish() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onShowFragment() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showActionBar() {
|
||||||
|
actionBar.setVisibility(View.VISIBLE);
|
||||||
|
needLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideActionBar() {
|
||||||
|
actionBar.setVisibility(View.GONE);
|
||||||
|
needLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_MENU && !checkTransitionAnimation() && !startedTracking) {
|
||||||
|
actionBar.onMenuButtonPressed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onKeyUp(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActionModeStarted(ActionMode mode) {
|
||||||
|
super.onActionModeStarted(mode);
|
||||||
|
hideActionBar();
|
||||||
|
inActionMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActionModeFinished(ActionMode mode) {
|
||||||
|
super.onActionModeFinished(mode);
|
||||||
|
showActionBar();
|
||||||
|
inActionMode = false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,433 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.4.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Views.ActionBar;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.Utilities;
|
||||||
|
|
||||||
|
public class ActionBarLayer extends FrameLayout {
|
||||||
|
|
||||||
|
public interface ActionBarMenuOnItemClick {
|
||||||
|
public abstract void onItemClick(int id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FrameLayout backButtonFrameLayout;
|
||||||
|
private ImageView logoImageView;
|
||||||
|
private ImageView backButtonImageView;
|
||||||
|
private TextView titleTextView;
|
||||||
|
private TextView subTitleTextView;
|
||||||
|
private ActionBarMenu menu;
|
||||||
|
private ActionBarMenu actionMode;
|
||||||
|
private ActionBar parentActionBar;
|
||||||
|
private boolean oldUseLogo;
|
||||||
|
private boolean oldUseBack;
|
||||||
|
protected boolean isSearchFieldVisible;
|
||||||
|
public ActionBarMenuOnItemClick actionBarMenuOnItemClick;
|
||||||
|
|
||||||
|
public ActionBarLayer(Context context, ActionBar actionBar) {
|
||||||
|
super(context);
|
||||||
|
parentActionBar = actionBar;
|
||||||
|
backButtonFrameLayout = new FrameLayout(context);
|
||||||
|
addView(backButtonFrameLayout);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)backButtonFrameLayout.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.FILL_PARENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
backButtonFrameLayout.setBackgroundResource(R.drawable.bar_selector);
|
||||||
|
backButtonFrameLayout.setLayoutParams(layoutParams);
|
||||||
|
backButtonFrameLayout.setPadding(0, 0, Utilities.dp(4), 0);
|
||||||
|
backButtonFrameLayout.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (isSearchFieldVisible) {
|
||||||
|
closeSearchField();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (actionBarMenuOnItemClick != null) {
|
||||||
|
actionBarMenuOnItemClick.onItemClick(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
backButtonFrameLayout.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarLayer(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarLayer(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarLayer(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void positionBackImage(int height) {
|
||||||
|
if (backButtonImageView != null) {
|
||||||
|
LayoutParams layoutParams = (LayoutParams)backButtonImageView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
layoutParams.setMargins(Utilities.dp(3), (height - backButtonImageView.getDrawable().getIntrinsicHeight()) / 2, 0, 0);
|
||||||
|
backButtonImageView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void positionLogoImage(int height) {
|
||||||
|
if (logoImageView != null) {
|
||||||
|
LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||||
|
layoutParams.height = (int)(logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
|
||||||
|
layoutParams.setMargins(Utilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
|
||||||
|
} else {
|
||||||
|
layoutParams.width = logoImageView.getDrawable().getIntrinsicWidth();
|
||||||
|
layoutParams.height = logoImageView.getDrawable().getIntrinsicHeight();
|
||||||
|
layoutParams.setMargins(Utilities.dp(12), (height - layoutParams.width) / 2, 0, 0);
|
||||||
|
}
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
logoImageView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void positionTitle(int width, int height) {
|
||||||
|
int offset = Utilities.dp(2);
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
offset = Utilities.dp(1);
|
||||||
|
}
|
||||||
|
int maxTextWidth = 0;
|
||||||
|
|
||||||
|
LayoutParams layoutParams = null;
|
||||||
|
|
||||||
|
if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) {
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
titleTextView.setTextSize(16);
|
||||||
|
} else {
|
||||||
|
titleTextView.setTextSize(18);
|
||||||
|
}
|
||||||
|
|
||||||
|
layoutParams = (LayoutParams) titleTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
titleTextView.setLayoutParams(layoutParams);
|
||||||
|
titleTextView.measure(width, height);
|
||||||
|
maxTextWidth = titleTextView.getMeasuredWidth();
|
||||||
|
}
|
||||||
|
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
subTitleTextView.setTextSize(12);
|
||||||
|
} else {
|
||||||
|
subTitleTextView.setTextSize(14);
|
||||||
|
}
|
||||||
|
|
||||||
|
layoutParams = (LayoutParams) subTitleTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
subTitleTextView.setLayoutParams(layoutParams);
|
||||||
|
subTitleTextView.measure(width, height);
|
||||||
|
maxTextWidth = Math.max(maxTextWidth, subTitleTextView.getMeasuredWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = 0;
|
||||||
|
if (logoImageView == null || logoImageView.getVisibility() == GONE) {
|
||||||
|
x = Utilities.dp(16);
|
||||||
|
} else {
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
x = Utilities.dp(22) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||||
|
} else {
|
||||||
|
x = Utilities.dp(22) + logoImageView.getDrawable().getIntrinsicWidth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu != null) {
|
||||||
|
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - Utilities.dp(16));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) {
|
||||||
|
layoutParams = (LayoutParams) titleTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = titleTextView.getMeasuredHeight();
|
||||||
|
int y = (height - titleTextView.getMeasuredHeight()) / 2;
|
||||||
|
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
|
||||||
|
y = (height / 2 - titleTextView.getMeasuredHeight()) / 2 + offset;
|
||||||
|
}
|
||||||
|
layoutParams.setMargins(x, y, 0, 0);
|
||||||
|
titleTextView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
|
||||||
|
layoutParams = (LayoutParams) subTitleTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = subTitleTextView.getMeasuredHeight();
|
||||||
|
layoutParams.setMargins(x, height / 2 + (height / 2 - subTitleTextView.getMeasuredHeight()) / 2 - offset, 0, 0);
|
||||||
|
subTitleTextView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewGroup.LayoutParams layoutParams1 = backButtonFrameLayout.getLayoutParams();
|
||||||
|
layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : Utilities.dp(6));
|
||||||
|
backButtonFrameLayout.setLayoutParams(layoutParams1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void positionMenu(int width, int height) {
|
||||||
|
if (menu == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams();
|
||||||
|
layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.leftMargin = isSearchFieldVisible ? Utilities.dp(26) + logoImageView.getDrawable().getIntrinsicWidth() : 0;
|
||||||
|
menu.setLayoutParams(layoutParams);
|
||||||
|
menu.measure(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayUseLogoEnabled(boolean value) {
|
||||||
|
if (value && logoImageView == null) {
|
||||||
|
logoImageView = new ImageView(getContext());
|
||||||
|
logoImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||||
|
logoImageView.setImageResource(R.drawable.ic_ab_logo);
|
||||||
|
backButtonFrameLayout.addView(logoImageView);
|
||||||
|
positionLogoImage(getMeasuredHeight());
|
||||||
|
} else if (logoImageView != null) {
|
||||||
|
logoImageView.setVisibility(value ? VISIBLE : GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayHomeAsUpEnabled(boolean value) {
|
||||||
|
if (value && backButtonImageView == null) {
|
||||||
|
backButtonImageView = new ImageView(getContext());
|
||||||
|
backButtonImageView.setImageResource(R.drawable.ic_ab_back);
|
||||||
|
backButtonFrameLayout.addView(backButtonImageView);
|
||||||
|
positionBackImage(getMeasuredHeight());
|
||||||
|
}
|
||||||
|
if (backButtonImageView != null) {
|
||||||
|
backButtonImageView.setVisibility(value ? VISIBLE : GONE);
|
||||||
|
backButtonFrameLayout.setEnabled(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubtitle(CharSequence value) {
|
||||||
|
if (value != null && subTitleTextView == null) {
|
||||||
|
subTitleTextView = new TextView(getContext());
|
||||||
|
backButtonFrameLayout.addView(subTitleTextView);
|
||||||
|
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||||
|
subTitleTextView.setSingleLine(true);
|
||||||
|
subTitleTextView.setLines(1);
|
||||||
|
subTitleTextView.setMaxLines(1);
|
||||||
|
subTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
}
|
||||||
|
if (subTitleTextView != null) {
|
||||||
|
subTitleTextView.setVisibility(value != null ? VISIBLE : GONE);
|
||||||
|
subTitleTextView.setText(value);
|
||||||
|
positionTitle(getMeasuredWidth(), getMeasuredHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTitleIcon(int resourceId, int padding) {
|
||||||
|
if (resourceId != 0 && subTitleTextView == null) {
|
||||||
|
subTitleTextView = new TextView(getContext());
|
||||||
|
backButtonFrameLayout.addView(subTitleTextView);
|
||||||
|
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||||
|
subTitleTextView.setSingleLine(true);
|
||||||
|
subTitleTextView.setLines(1);
|
||||||
|
subTitleTextView.setMaxLines(1);
|
||||||
|
subTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
positionTitle(getMeasuredWidth(), getMeasuredHeight());
|
||||||
|
}
|
||||||
|
if (subTitleTextView != null) {
|
||||||
|
subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0);
|
||||||
|
subTitleTextView.setCompoundDrawablePadding(padding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(CharSequence value) {
|
||||||
|
if (value != null && titleTextView == null) {
|
||||||
|
titleTextView = new TextView(getContext());
|
||||||
|
titleTextView.setSingleLine(true);
|
||||||
|
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
backButtonFrameLayout.addView(titleTextView);
|
||||||
|
titleTextView.setTextColor(0xffffffff);
|
||||||
|
}
|
||||||
|
if (titleTextView != null) {
|
||||||
|
titleTextView.setVisibility(value != null ? VISIBLE : GONE);
|
||||||
|
titleTextView.setText(value);
|
||||||
|
positionTitle(getMeasuredWidth(), getMeasuredHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitleIcon(int resourceId, int padding) {
|
||||||
|
if (resourceId != 0 && titleTextView == null) {
|
||||||
|
titleTextView = new TextView(getContext());
|
||||||
|
backButtonFrameLayout.addView(titleTextView);
|
||||||
|
titleTextView.setTextColor(0xffffffff);
|
||||||
|
titleTextView.setSingleLine(true);
|
||||||
|
titleTextView.setLines(1);
|
||||||
|
titleTextView.setMaxLines(1);
|
||||||
|
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
positionTitle(getMeasuredWidth(), getMeasuredHeight());
|
||||||
|
}
|
||||||
|
titleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0);
|
||||||
|
titleTextView.setCompoundDrawablePadding(padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getSubTitleIcon() {
|
||||||
|
return subTitleTextView.getCompoundDrawables()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence getTitle() {
|
||||||
|
if (titleTextView == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return titleTextView.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenu createMenu() {
|
||||||
|
if (menu != null) {
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
menu = new ActionBarMenu(getContext(), parentActionBar, this);
|
||||||
|
addView(menu);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams();
|
||||||
|
layoutParams.height = LayoutParams.FILL_PARENT;
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.RIGHT;
|
||||||
|
menu.setLayoutParams(layoutParams);
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDestroy() {
|
||||||
|
parentActionBar.detachActionBarLayer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionBarMenuOnItemClick(ActionBarMenuOnItemClick listener) {
|
||||||
|
actionBarMenuOnItemClick = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomView(int resourceId) {
|
||||||
|
LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View view = li.inflate(resourceId, null);
|
||||||
|
addView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackLayoutVisible(int visibility) {
|
||||||
|
backButtonFrameLayout.setVisibility(visibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBackLayoutWidth() {
|
||||||
|
if (menu != null) {
|
||||||
|
return getMeasuredWidth() - menu.getMeasuredWidth();
|
||||||
|
}
|
||||||
|
return getMeasuredWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenu createActionMode() {
|
||||||
|
if (actionMode != null) {
|
||||||
|
return actionMode;
|
||||||
|
}
|
||||||
|
actionMode = new ActionBarMenu(getContext(), parentActionBar, this);
|
||||||
|
actionMode.setBackgroundResource(R.drawable.editheader);
|
||||||
|
addView(actionMode);
|
||||||
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams();
|
||||||
|
layoutParams.height = LayoutParams.FILL_PARENT;
|
||||||
|
layoutParams.width = LayoutParams.FILL_PARENT;
|
||||||
|
layoutParams.gravity = Gravity.RIGHT;
|
||||||
|
actionMode.setLayoutParams(layoutParams);
|
||||||
|
actionMode.setVisibility(GONE);
|
||||||
|
return actionMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showActionMode() {
|
||||||
|
if (actionMode == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
actionMode.setVisibility(VISIBLE);
|
||||||
|
if (backButtonFrameLayout != null) {
|
||||||
|
backButtonFrameLayout.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
if (menu != null) {
|
||||||
|
menu.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideActionMode() {
|
||||||
|
if (actionMode == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
actionMode.setVisibility(GONE);
|
||||||
|
if (backButtonFrameLayout != null) {
|
||||||
|
backButtonFrameLayout.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
if (menu != null) {
|
||||||
|
menu.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActionModeShowed() {
|
||||||
|
return actionMode != null && actionMode.getVisibility() == VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onSearchFieldVisibilityChanged(boolean visible) {
|
||||||
|
isSearchFieldVisible = visible;
|
||||||
|
if (titleTextView != null) {
|
||||||
|
titleTextView.setVisibility(visible ? GONE : VISIBLE);
|
||||||
|
}
|
||||||
|
if (subTitleTextView != null) {
|
||||||
|
subTitleTextView.setVisibility(visible ? GONE : VISIBLE);
|
||||||
|
}
|
||||||
|
backButtonFrameLayout.setPadding(0, 0, visible ? 0 : Utilities.dp(4), 0);
|
||||||
|
if (visible) {
|
||||||
|
oldUseLogo = logoImageView != null && logoImageView.getVisibility() == VISIBLE;
|
||||||
|
setDisplayUseLogoEnabled(true);
|
||||||
|
} else {
|
||||||
|
setDisplayUseLogoEnabled(oldUseLogo);
|
||||||
|
}
|
||||||
|
if (visible) {
|
||||||
|
oldUseBack = backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE;
|
||||||
|
setDisplayHomeAsUpEnabled(true);
|
||||||
|
} else {
|
||||||
|
setDisplayHomeAsUpEnabled(oldUseBack);
|
||||||
|
}
|
||||||
|
logoImageView.setImageResource(visible ? R.drawable.ic_ab_search : R.drawable.ic_ab_logo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeSearchField() {
|
||||||
|
if (!isSearchFieldVisible || menu == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
menu.closeSearchField();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
positionLogoImage(MeasureSpec.getSize(heightMeasureSpec));
|
||||||
|
positionBackImage(MeasureSpec.getSize(heightMeasureSpec));
|
||||||
|
positionMenu(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
|
||||||
|
positionTitle(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMenuButtonPressed() {
|
||||||
|
if (menu != null) {
|
||||||
|
menu.onMenuButtonPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.4.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Views.ActionBar;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.Utilities;
|
||||||
|
|
||||||
|
public class ActionBarMenu extends LinearLayout {
|
||||||
|
|
||||||
|
private ActionBar parentActionBar;
|
||||||
|
private ActionBarLayer parentActionBarLayer;
|
||||||
|
|
||||||
|
public ActionBarMenu(Context context, ActionBar actionBar, ActionBarLayer layer) {
|
||||||
|
super(context);
|
||||||
|
setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
parentActionBar = actionBar;
|
||||||
|
parentActionBarLayer = layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenu(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenu(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenu(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public View addItemResource(int id, int resourceId) {
|
||||||
|
LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View view = li.inflate(resourceId, null);
|
||||||
|
view.setTag(id);
|
||||||
|
addView(view);
|
||||||
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)view.getLayoutParams();
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.FILL_PARENT;
|
||||||
|
view.setBackgroundResource(R.drawable.bar_selector);
|
||||||
|
view.setLayoutParams(layoutParams);
|
||||||
|
view.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
onItemClick((Integer)view.getTag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenuItem addItem(int id, int icon) {
|
||||||
|
ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, parentActionBar);
|
||||||
|
menuItem.setTag(id);
|
||||||
|
menuItem.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
menuItem.setImageResource(icon);
|
||||||
|
addView(menuItem);
|
||||||
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams();
|
||||||
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.width = Utilities.dp(56);
|
||||||
|
menuItem.setLayoutParams(layoutParams);
|
||||||
|
menuItem.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
ActionBarMenuItem item = (ActionBarMenuItem)view;
|
||||||
|
if (item.hasSubMenu()) {
|
||||||
|
item.toggleSubMenu();
|
||||||
|
} else if (item.isSearchField()) {
|
||||||
|
parentActionBarLayer.onSearchFieldVisibilityChanged(item.toggleSearch());
|
||||||
|
} else {
|
||||||
|
onItemClick((Integer)view.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return menuItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDestroy() {
|
||||||
|
for (int a = 0; a < getChildCount(); a++) {
|
||||||
|
View view = getChildAt(a);
|
||||||
|
if (view instanceof ActionBarMenuItem) {
|
||||||
|
((ActionBarMenuItem)view).closeSubMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onItemClick(int id) {
|
||||||
|
if (parentActionBarLayer.actionBarMenuOnItemClick != null) {
|
||||||
|
parentActionBarLayer.actionBarMenuOnItemClick.onItemClick(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearItems() {
|
||||||
|
for (int a = 0; a < getChildCount(); a++) {
|
||||||
|
View view = getChildAt(a);
|
||||||
|
removeView(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMenuButtonPressed() {
|
||||||
|
for (int a = 0; a < getChildCount(); a++) {
|
||||||
|
View view = getChildAt(a);
|
||||||
|
if (view instanceof ActionBarMenuItem) {
|
||||||
|
ActionBarMenuItem item = (ActionBarMenuItem)view;
|
||||||
|
if (item.hasSubMenu()) {
|
||||||
|
item.toggleSubMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeSearchField() {
|
||||||
|
for (int a = 0; a < getChildCount(); a++) {
|
||||||
|
View view = getChildAt(a);
|
||||||
|
if (view instanceof ActionBarMenuItem) {
|
||||||
|
ActionBarMenuItem item = (ActionBarMenuItem)view;
|
||||||
|
if (item.isSearchField()) {
|
||||||
|
parentActionBarLayer.onSearchFieldVisibilityChanged(item.toggleSearch());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenuItem getItem(int id) {
|
||||||
|
View v = findViewWithTag(id);
|
||||||
|
if (v instanceof ActionBarMenuItem) {
|
||||||
|
return (ActionBarMenuItem)v;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,259 @@
|
|||||||
|
/*
|
||||||
|
* This is the source code of Telegram for Android v. 1.4.x.
|
||||||
|
* It is licensed under GNU GPL v. 2 or later.
|
||||||
|
* You should have received a copy of the license in this archive (see LICENSE).
|
||||||
|
*
|
||||||
|
* Copyright Nikolai Kudashov, 2013-2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.telegram.ui.Views.ActionBar;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.PopupWindow;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.Utilities;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class ActionBarMenuItem extends ImageView {
|
||||||
|
|
||||||
|
public static interface ActionBarMenuItemSearchListener {
|
||||||
|
public abstract void onSearchExpand();
|
||||||
|
public abstract void onSearchCollapse();
|
||||||
|
public abstract void onTextChanged(EditText editText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinearLayout popupLayout;
|
||||||
|
private ActionBarMenu parentMenu;
|
||||||
|
private PopupWindow popupWindow;
|
||||||
|
private ActionBar parentActionBar;
|
||||||
|
private EditText searchField;
|
||||||
|
private boolean isSearchField = false;
|
||||||
|
private ActionBarMenuItemSearchListener listener;
|
||||||
|
|
||||||
|
public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar) {
|
||||||
|
super(context);
|
||||||
|
setBackgroundResource(R.drawable.bar_selector);
|
||||||
|
parentMenu = menu;
|
||||||
|
parentActionBar = actionBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenuItem(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenuItem(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenuItem(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSubItem(int id, String text, int icon) {
|
||||||
|
if (popupLayout == null) {
|
||||||
|
popupLayout = new LinearLayout(getContext());
|
||||||
|
popupLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
popupLayout.setBackgroundResource(R.drawable.popup_fixed);
|
||||||
|
}
|
||||||
|
if (popupLayout.getChildCount() != 0) {
|
||||||
|
View delimeter = new View(getContext());
|
||||||
|
delimeter.setBackgroundColor(0xffdcdcdc);
|
||||||
|
popupLayout.addView(delimeter);
|
||||||
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)delimeter.getLayoutParams();
|
||||||
|
layoutParams.width = Utilities.dp(196);
|
||||||
|
layoutParams.height = Utilities.density >= 3 ? 2 : 1;
|
||||||
|
delimeter.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
TextView textView = new TextView(getContext());
|
||||||
|
textView.setTextColor(0xff000000);
|
||||||
|
textView.setBackgroundResource(R.drawable.list_selector);
|
||||||
|
textView.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
textView.setPadding(Utilities.dp(16), 0, Utilities.dp(16), 0);
|
||||||
|
textView.setTextSize(18);
|
||||||
|
textView.setMinWidth(Utilities.dp(196));
|
||||||
|
textView.setTag(id);
|
||||||
|
textView.setText(text);
|
||||||
|
if (icon != 0) {
|
||||||
|
textView.setCompoundDrawablePadding(Utilities.dp(12));
|
||||||
|
textView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(icon), null, null, null);
|
||||||
|
}
|
||||||
|
popupLayout.addView(textView);
|
||||||
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)textView.getLayoutParams();
|
||||||
|
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = Utilities.dp(48);
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
textView.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
parentMenu.onItemClick((Integer) view.getTag());
|
||||||
|
if (popupWindow != null && popupWindow.isShowing()) {
|
||||||
|
popupWindow.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSubMenu() {
|
||||||
|
return popupLayout != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleSubMenu() {
|
||||||
|
if (popupWindow != null && popupWindow.isShowing()) {
|
||||||
|
popupWindow.dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (popupWindow == null) {
|
||||||
|
popupWindow = new PopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
popupWindow.setFocusable(true);
|
||||||
|
popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
||||||
|
popupWindow.setOutsideTouchable(true);
|
||||||
|
popupWindow.setClippingEnabled(true);
|
||||||
|
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||||
|
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
||||||
|
}
|
||||||
|
if (popupLayout.getMeasuredWidth() == 0) {
|
||||||
|
popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0);
|
||||||
|
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0, -1, -1);
|
||||||
|
} else {
|
||||||
|
popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean toggleSearch() {
|
||||||
|
if (searchField == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (searchField.getVisibility() == VISIBLE) {
|
||||||
|
searchField.setVisibility(GONE);
|
||||||
|
setVisibility(VISIBLE);
|
||||||
|
Utilities.hideKeyboard(searchField);
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onSearchCollapse();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
searchField.setVisibility(VISIBLE);
|
||||||
|
setVisibility(GONE);
|
||||||
|
searchField.setText("");
|
||||||
|
searchField.requestFocus();
|
||||||
|
Utilities.showKeyboard(searchField);
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onSearchExpand();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeSubMenu() {
|
||||||
|
if (popupWindow != null && popupWindow.isShowing()) {
|
||||||
|
popupWindow.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditText getSearchField() {
|
||||||
|
return searchField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarMenuItem setIsSearchField(boolean value) {
|
||||||
|
if (value && searchField == null) {
|
||||||
|
searchField = new EditText(getContext());
|
||||||
|
searchField.setTextSize(18);
|
||||||
|
searchField.setTextColor(0xffffffff);
|
||||||
|
searchField.setSingleLine(true);
|
||||||
|
searchField.setTextIsSelectable(false);
|
||||||
|
searchField.setBackgroundResource(R.drawable.search_light_states);
|
||||||
|
searchField.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
|
||||||
|
searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
|
searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || event != null && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
|
||||||
|
Utilities.hideKeyboard(searchField);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
searchField.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onTextChanged(searchField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
|
||||||
|
if (img != null) {
|
||||||
|
img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
||||||
|
mCursorDrawableRes.setAccessible(true);
|
||||||
|
mCursorDrawableRes.set(searchField, R.drawable.search_carret);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
|
searchField.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_ACTION_SEARCH);
|
||||||
|
} else {
|
||||||
|
searchField.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
||||||
|
}
|
||||||
|
parentMenu.addView(searchField, 0);
|
||||||
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)searchField.getLayoutParams();
|
||||||
|
layoutParams.weight = 1;
|
||||||
|
layoutParams.width = 0;
|
||||||
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
layoutParams.height = Utilities.dp(36);
|
||||||
|
layoutParams.rightMargin = Utilities.dp(4);
|
||||||
|
searchField.setLayoutParams(layoutParams);
|
||||||
|
searchField.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
isSearchField = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSearchField() {
|
||||||
|
return isSearchField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionBarMenuItemSearchListener(ActionBarMenuItemSearchListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
if (popupWindow != null && popupWindow.isShowing()) {
|
||||||
|
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0, -1, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* 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.ActionBar;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
|
|
||||||
|
public class BaseFragment {
|
||||||
|
private boolean isFinished = false;
|
||||||
|
protected View fragmentView;
|
||||||
|
private ActionBarActivity parentActivity;
|
||||||
|
protected ActionBarLayer actionBarLayer;
|
||||||
|
protected int classGuid = 0;
|
||||||
|
protected Bundle arguments;
|
||||||
|
|
||||||
|
public BaseFragment() {
|
||||||
|
classGuid = ConnectionsManager.getInstance().generateClassGuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseFragment(Bundle args) {
|
||||||
|
arguments = args;
|
||||||
|
classGuid = ConnectionsManager.getInstance().generateClassGuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bundle getArguments() {
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentActivity(ActionBarActivity activity) {
|
||||||
|
if (parentActivity != activity) {
|
||||||
|
parentActivity = activity;
|
||||||
|
if (fragmentView != null) {
|
||||||
|
ViewGroup parent = (ViewGroup) fragmentView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(fragmentView);
|
||||||
|
}
|
||||||
|
fragmentView = null;
|
||||||
|
}
|
||||||
|
if (parentActivity != null) {
|
||||||
|
if (actionBarLayer != null) {
|
||||||
|
actionBarLayer.onDestroy();
|
||||||
|
actionBarLayer = null;
|
||||||
|
}
|
||||||
|
actionBarLayer = parentActivity.getInternalActionBar().createLayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishFragment() {
|
||||||
|
if (isFinished || parentActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentActivity.closeLastFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSelfFromStack() {
|
||||||
|
if (isFinished || parentActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentActivity.removeFragmentFromStack(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onFragmentCreate() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFragmentDestroy() {
|
||||||
|
ConnectionsManager.getInstance().cancelRpcsForClassGuid(classGuid);
|
||||||
|
isFinished = true;
|
||||||
|
if (actionBarLayer != null) {
|
||||||
|
actionBarLayer.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onResume() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPause() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBackPressed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveSelfArgs(Bundle args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreSelfArgs(Bundle args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void presentFragment(BaseFragment fragment) {
|
||||||
|
if (parentActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentActivity.presentFragment(fragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void presentFragment(BaseFragment fragment, boolean removeLast) {
|
||||||
|
if (parentActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentActivity.presentFragment(fragment, removeLast);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void presentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation) {
|
||||||
|
if (parentActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentActivity.presentFragment(fragment, removeLast, forceWithoutAnimation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarActivity getParentActivity() {
|
||||||
|
return parentActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showActionBar() {
|
||||||
|
if (parentActivity != null) {
|
||||||
|
parentActivity.showActionBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideActionBar() {
|
||||||
|
if (parentActivity != null) {
|
||||||
|
parentActivity.hideActionBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBeginSlide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onOpenAnimationEnd() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onLowMemory() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ import org.telegram.messenger.UserConfig;
|
|||||||
import org.telegram.messenger.Utilities;
|
import org.telegram.messenger.Utilities;
|
||||||
import org.telegram.ui.LaunchActivity;
|
import org.telegram.ui.LaunchActivity;
|
||||||
import org.telegram.ui.PhotoCropActivity;
|
import org.telegram.ui.PhotoCropActivity;
|
||||||
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
|||||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
||||||
currentPicturePath = image.getAbsolutePath();
|
currentPicturePath = image.getAbsolutePath();
|
||||||
}
|
}
|
||||||
parentFragment.parentActivity.startActivityForResult(takePictureIntent, 13);
|
parentFragment.getParentActivity().startActivityForResult(takePictureIntent, 13);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
@ -68,7 +69,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
|||||||
try {
|
try {
|
||||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||||
photoPickerIntent.setType("image/*");
|
photoPickerIntent.setType("image/*");
|
||||||
parentFragment.parentActivity.startActivityForResult(photoPickerIntent, 14);
|
parentFragment.getParentActivity().startActivityForResult(photoPickerIntent, 14);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
@ -76,23 +77,19 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
|||||||
|
|
||||||
private void startCrop(String path, Uri uri) {
|
private void startCrop(String path, Uri uri) {
|
||||||
try {
|
try {
|
||||||
LaunchActivity activity = (LaunchActivity)parentFragment.parentActivity;
|
LaunchActivity activity = (LaunchActivity)parentFragment.getParentActivity();
|
||||||
if (activity == null) {
|
|
||||||
activity = (LaunchActivity)parentFragment.getActivity();
|
|
||||||
}
|
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bundle params = new Bundle();
|
Bundle args = new Bundle();
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
params.putString("photoPath", path);
|
args.putString("photoPath", path);
|
||||||
} else if (uri != null) {
|
} else if (uri != null) {
|
||||||
params.putParcelable("photoUri", uri);
|
args.putParcelable("photoUri", uri);
|
||||||
}
|
}
|
||||||
PhotoCropActivity photoCropActivity = new PhotoCropActivity();
|
PhotoCropActivity photoCropActivity = new PhotoCropActivity(args);
|
||||||
photoCropActivity.delegate = this;
|
photoCropActivity.setDelegate(this);
|
||||||
photoCropActivity.setArguments(params);
|
activity.presentFragment(photoCropActivity);
|
||||||
activity.presentFragment(photoCropActivity, "crop", false);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
Bitmap bitmap = FileLoader.loadBitmap(path, uri, 800, 800);
|
Bitmap bitmap = FileLoader.loadBitmap(path, uri, 800, 800);
|
||||||
|
@ -24,6 +24,7 @@ import org.telegram.messenger.Utilities;
|
|||||||
public class BackupImageView extends ImageView {
|
public class BackupImageView extends ImageView {
|
||||||
boolean makeRequest = true;
|
boolean makeRequest = true;
|
||||||
public String currentPath;
|
public String currentPath;
|
||||||
|
public boolean processDetach = true;
|
||||||
private boolean isPlaceholder;
|
private boolean isPlaceholder;
|
||||||
private boolean ignoreLayout = true;
|
private boolean ignoreLayout = true;
|
||||||
|
|
||||||
@ -179,7 +180,9 @@ public class BackupImageView extends ImageView {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
recycleBitmap(null);
|
if (processDetach) {
|
||||||
|
recycleBitmap(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,196 +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.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
|
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
|
||||||
import org.telegram.ui.LaunchActivity;
|
|
||||||
import org.telegram.ui.ApplicationLoader;
|
|
||||||
|
|
||||||
public class BaseFragment extends Fragment {
|
|
||||||
public int animationType = 0;
|
|
||||||
public boolean isFinish = false;
|
|
||||||
public View fragmentView;
|
|
||||||
public ActionBarActivity parentActivity;
|
|
||||||
public int classGuid = 0;
|
|
||||||
public boolean firstStart = true;
|
|
||||||
public boolean animationInProgress = false;
|
|
||||||
private long currentAnimationDuration = 0;
|
|
||||||
private boolean removeParentOnDestroy = false;
|
|
||||||
private boolean removeParentOnAnimationEnd = true;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
parentActivity = (ActionBarActivity)getActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void willBeHidden() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishFragment() {
|
|
||||||
finishFragment(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishFragment(boolean bySwipe) {
|
|
||||||
if (isFinish || animationInProgress) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
isFinish = true;
|
|
||||||
if (parentActivity == null) {
|
|
||||||
ApplicationLoader.fragmentsStack.remove(this);
|
|
||||||
onFragmentDestroy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).finishFragment(bySwipe);
|
|
||||||
if (getActivity() == null) {
|
|
||||||
if (fragmentView != null) {
|
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
||||||
if (parent != null) {
|
|
||||||
parent.removeView(fragmentView);
|
|
||||||
}
|
|
||||||
fragmentView = null;
|
|
||||||
}
|
|
||||||
parentActivity = null;
|
|
||||||
} else {
|
|
||||||
removeParentOnDestroy = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSelfFromStack() {
|
|
||||||
if (isFinish) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
isFinish = true;
|
|
||||||
if (parentActivity == null) {
|
|
||||||
ApplicationLoader.fragmentsStack.remove(this);
|
|
||||||
onFragmentDestroy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((LaunchActivity)parentActivity).removeFromStack(this);
|
|
||||||
if (getActivity() == null) {
|
|
||||||
if (fragmentView != null) {
|
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
||||||
if (parent != null) {
|
|
||||||
parent.removeView(fragmentView);
|
|
||||||
}
|
|
||||||
fragmentView = null;
|
|
||||||
}
|
|
||||||
parentActivity = null;
|
|
||||||
} else {
|
|
||||||
removeParentOnDestroy = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onFragmentCreate() {
|
|
||||||
classGuid = ConnectionsManager.getInstance().generateClassGuid();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onFragmentDestroy() {
|
|
||||||
ConnectionsManager.getInstance().cancelRpcsForClassGuid(classGuid);
|
|
||||||
removeParentOnDestroy = true;
|
|
||||||
isFinish = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationStart() {
|
|
||||||
animationInProgress = true;
|
|
||||||
if (fragmentView != null) {
|
|
||||||
fragmentView.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (animationInProgress) {
|
|
||||||
onAnimationEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, currentAnimationDuration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationEnd() {
|
|
||||||
animationInProgress = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onBackPressed() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (removeParentOnDestroy) {
|
|
||||||
if (fragmentView != null) {
|
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
||||||
if (parent != null) {
|
|
||||||
parent.removeView(fragmentView);
|
|
||||||
}
|
|
||||||
fragmentView = null;
|
|
||||||
}
|
|
||||||
parentActivity = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
|
||||||
if (nextAnim != 0) {
|
|
||||||
Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
|
|
||||||
currentAnimationDuration = anim.getDuration();
|
|
||||||
|
|
||||||
anim.setAnimationListener(new Animation.AnimationListener() {
|
|
||||||
|
|
||||||
public void onAnimationStart(Animation animation) {
|
|
||||||
BaseFragment.this.onAnimationStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationRepeat(Animation animation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onAnimationEnd(Animation animation) {
|
|
||||||
if (animationInProgress) {
|
|
||||||
BaseFragment.this.onAnimationEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return anim;
|
|
||||||
} else {
|
|
||||||
return super.onCreateAnimation(transit, enter, nextAnim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canApplyUpdateStatus() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applySelfActionBar() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveSelfArgs(Bundle args) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restoreSelfArgs(Bundle args) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,149 +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.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnTouchListener;
|
|
||||||
import android.widget.GridView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
public class OnSwipeTouchListener implements OnTouchListener {
|
|
||||||
private float downX, downY;
|
|
||||||
private boolean discard = false;
|
|
||||||
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
switch(event.getAction()){
|
|
||||||
case MotionEvent.ACTION_DOWN: {
|
|
||||||
downX = event.getX();
|
|
||||||
downY = event.getY();
|
|
||||||
discard = false;
|
|
||||||
return !(v instanceof ListView || v instanceof GridView);
|
|
||||||
}
|
|
||||||
case MotionEvent.ACTION_MOVE: {
|
|
||||||
float upX = event.getX();
|
|
||||||
float upY = event.getY();
|
|
||||||
|
|
||||||
float deltaX = downX - upX;
|
|
||||||
float deltaY = downY - upY;
|
|
||||||
if (Math.abs(deltaY) > 40) {
|
|
||||||
discard = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!discard && Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > 90) {
|
|
||||||
if(deltaX < 0) {
|
|
||||||
onSwipeRight();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(deltaX > 0) {
|
|
||||||
onSwipeLeft();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MotionEvent.ACTION_UP: {
|
|
||||||
onTouchUp(event);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*private final GestureDetector gestureDetector = new GestureDetector(new GestureListener());
|
|
||||||
|
|
||||||
public boolean onTouch(final View view, final MotionEvent motionEvent) {
|
|
||||||
return gestureDetector.onTouchEvent(motionEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class GestureListener extends SimpleOnGestureListener {
|
|
||||||
|
|
||||||
private static final int SWIPE_THRESHOLD = 100;
|
|
||||||
private static final int SWIPE_VELOCITY_THRESHOLD = 100;
|
|
||||||
private long lastTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onDown(MotionEvent e) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
|
||||||
boolean result = false;
|
|
||||||
try {
|
|
||||||
int mask = e1.getActionMasked();
|
|
||||||
Log.e("tmessages", "event1" + e1);
|
|
||||||
Log.e("tmessages", "event2" + e2);
|
|
||||||
float diffY = e2.getY() - e1.getY();
|
|
||||||
float diffX = e2.getX() - e1.getX();
|
|
||||||
float velocityX = 0;
|
|
||||||
if (lastTime != 0)
|
|
||||||
if (Math.abs(diffX) > Math.abs(diffY)) {
|
|
||||||
if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
|
||||||
if (diffX > 0) {
|
|
||||||
onSwipeRight();
|
|
||||||
} else {
|
|
||||||
onSwipeLeft();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
|
||||||
// boolean result = false;
|
|
||||||
// try {
|
|
||||||
// float diffY = e2.getY() - e1.getY();
|
|
||||||
// float diffX = e2.getX() - e1.getX();
|
|
||||||
// if (Math.abs(diffX) > Math.abs(diffY)) {
|
|
||||||
// if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
|
||||||
// if (diffX > 0) {
|
|
||||||
// onSwipeRight();
|
|
||||||
// } else {
|
|
||||||
// onSwipeLeft();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
|
|
||||||
// if (diffY > 0) {
|
|
||||||
// onSwipeBottom();
|
|
||||||
// } else {
|
|
||||||
// onSwipeTop();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (Exception exception) {
|
|
||||||
// exception.printStackTrace();
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public void onTouchUp(MotionEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSwipeRight() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSwipeLeft() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<alpha android:fromAlpha="1.0"
|
|
||||||
android:toAlpha="0.0"
|
|
||||||
android:duration="150" />
|
|
||||||
</set>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<alpha android:fromAlpha="0.0"
|
|
||||||
android:toAlpha="1.0"
|
|
||||||
android:duration="150" />
|
|
||||||
</set>
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<translate
|
|
||||||
android:fromXDelta="100%"
|
|
||||||
android:toXDelta="0"
|
|
||||||
android:duration="150"/>
|
|
||||||
</set>
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<translate
|
|
||||||
android:fromXDelta="0"
|
|
||||||
android:toXDelta="-100%"
|
|
||||||
android:duration="150"/>
|
|
||||||
</set>
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<translate
|
|
||||||
android:fromXDelta="-100%"
|
|
||||||
android:toXDelta="0"
|
|
||||||
android:duration="150"/>
|
|
||||||
</set>
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<set>
|
|
||||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:fromXDelta="0"
|
|
||||||
android:toXDelta="100%"
|
|
||||||
android:duration="150"/>
|
|
||||||
</set>
|
|
BIN
TMessagesProj/src/main/res/drawable-hdpi/editheader.9.png
Normal file
After Width: | Height: | Size: 134 B |
Before Width: | Height: | Size: 136 B |
BIN
TMessagesProj/src/main/res/drawable-hdpi/search_light.9.png
Executable file
After Width: | Height: | Size: 105 B |
BIN
TMessagesProj/src/main/res/drawable-hdpi/search_light_selected.9.png
Executable file
After Width: | Height: | Size: 112 B |
BIN
TMessagesProj/src/main/res/drawable-ldpi/editheader.9.png
Normal file
After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 108 B |
BIN
TMessagesProj/src/main/res/drawable-mdpi/editheader.9.png
Normal file
After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 119 B |
BIN
TMessagesProj/src/main/res/drawable-mdpi/search_light.9.png
Executable file
After Width: | Height: | Size: 100 B |
BIN
TMessagesProj/src/main/res/drawable-mdpi/search_light_selected.9.png
Executable file
After Width: | Height: | Size: 109 B |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/editheader.9.png
Normal file
After Width: | Height: | Size: 152 B |
Before Width: | Height: | Size: 148 B |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/search_light.9.png
Executable file
After Width: | Height: | Size: 126 B |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/search_light_selected.9.png
Executable file
After Width: | Height: | Size: 126 B |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/editheader.9.png
Normal file
After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 189 B |
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
|
||||||
<item android:drawable="@drawable/ic_ab_logo"
|
|
||||||
android:left="-6dp"/>
|
|
||||||
</layer-list>
|
|
8
TMessagesProj/src/main/res/drawable/search_light_states.xml
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_focused="true"
|
||||||
|
android:drawable="@drawable/search_light_selected" />
|
||||||
|
<item android:drawable="@drawable/search_light" />
|
||||||
|
</selector>
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
android:layout_width="fill_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="fill_parent">
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
<org.telegram.ui.Views.PinnedHeaderListView
|
<org.telegram.ui.Views.PinnedHeaderListView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -1,51 +1,59 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="top">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="top">
|
||||||
|
|
||||||
<FrameLayout android:id="@+id/map_view"
|
<com.google.android.gms.maps.MapView
|
||||||
|
android:id="@+id/map_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="top"/>
|
android:layout_gravity="top"/>
|
||||||
|
|
||||||
<FrameLayout android:layout_width="fill_parent"
|
<FrameLayout
|
||||||
android:layout_height="91dp"
|
android:layout_width="fill_parent"
|
||||||
android:layout_gravity="bottom"
|
android:layout_height="91dp"
|
||||||
android:background="@drawable/location_panel"
|
android:layout_gravity="bottom"
|
||||||
android:id="@+id/location_bottom_view">
|
android:background="@drawable/location_panel"
|
||||||
|
android:id="@+id/location_bottom_view">
|
||||||
|
|
||||||
<org.telegram.ui.Views.BackupImageView
|
<org.telegram.ui.Views.BackupImageView
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:contentDescription=""
|
android:contentDescription=""
|
||||||
android:id="@+id/location_avatar_view"
|
android:id="@+id/location_avatar_view"
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_gravity="top|right"/>
|
android:layout_gravity="top|right"/>
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content"
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:textSize="22dp"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#000000"
|
android:textSize="22dp"
|
||||||
android:layout_marginRight="88dp"
|
android:textColor="#000000"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginRight="88dp"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginTop="20dp"
|
||||||
android:id="@+id/location_name_label"
|
android:layout_marginLeft="12dp"
|
||||||
android:layout_gravity="top|right"
|
android:id="@+id/location_name_label"
|
||||||
android:maxLines="1"
|
android:layout_gravity="top|right"
|
||||||
android:gravity="right"/>
|
android:maxLines="1"
|
||||||
|
android:gravity="right"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="15dp"
|
||||||
|
android:layout_marginRight="88dp"
|
||||||
|
android:layout_marginTop="52dp"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:textColor="#999999"
|
||||||
|
android:id="@+id/location_distance_label"
|
||||||
|
android:layout_gravity="top|right"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:gravity="right"/>
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="15dp"
|
|
||||||
android:layout_marginRight="88dp"
|
|
||||||
android:layout_marginTop="52dp"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:textColor="#999999"
|
|
||||||
android:id="@+id/location_distance_label"
|
|
||||||
android:layout_gravity="top|right"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:gravity="right"/>
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="top"
|
|
||||||
android:background="#ffffff">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="top"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@ -1,6 +1,7 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
android:layout_width="fill_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="fill_parent">
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
<org.telegram.ui.Views.PinnedHeaderListView
|
<org.telegram.ui.Views.PinnedHeaderListView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -1,25 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="top">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="top">
|
||||||
|
|
||||||
<FrameLayout android:id="@+id/map_view"
|
<com.google.android.gms.maps.MapView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/map_view"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="top"/>
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="top"/>
|
||||||
|
|
||||||
<TextView android:layout_width="match_parent"
|
<TextView
|
||||||
android:layout_height="50dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="bottom"
|
android:layout_height="50dp"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_gravity="bottom"
|
||||||
android:layout_marginRight="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginRight="15dp"
|
||||||
android:gravity="center"
|
android:layout_marginLeft="15dp"
|
||||||
android:textSize="18dp"
|
android:gravity="center"
|
||||||
android:textColor="#316f9f"
|
android:textSize="18dp"
|
||||||
android:background="@drawable/location_send_button_states"
|
android:textColor="#316f9f"
|
||||||
android:id="@+id/location_send_button"/>
|
android:background="@drawable/location_send_button_states"
|
||||||
|
android:id="@+id/location_send_button"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -1,49 +1,57 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="top">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="top">
|
||||||
|
|
||||||
<FrameLayout android:id="@+id/map_view"
|
<com.google.android.gms.maps.MapView
|
||||||
|
android:id="@+id/map_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="top"/>
|
android:layout_gravity="top"/>
|
||||||
|
|
||||||
<FrameLayout android:layout_width="fill_parent"
|
<FrameLayout
|
||||||
android:layout_height="91dp"
|
android:layout_width="fill_parent"
|
||||||
android:layout_gravity="bottom"
|
android:layout_height="91dp"
|
||||||
android:background="@drawable/location_panel"
|
android:layout_gravity="bottom"
|
||||||
android:id="@+id/location_bottom_view">
|
android:background="@drawable/location_panel"
|
||||||
|
android:id="@+id/location_bottom_view">
|
||||||
|
|
||||||
<org.telegram.ui.Views.BackupImageView
|
<org.telegram.ui.Views.BackupImageView
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:contentDescription=""
|
android:contentDescription=""
|
||||||
android:id="@+id/location_avatar_view"
|
android:id="@+id/location_avatar_view"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_gravity="top"/>
|
android:layout_gravity="top"/>
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content"
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:textSize="22dp"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#000000"
|
android:textSize="22dp"
|
||||||
android:layout_marginLeft="88dp"
|
android:textColor="#000000"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginLeft="88dp"
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginTop="20dp"
|
||||||
android:id="@+id/location_name_label"
|
android:layout_marginRight="12dp"
|
||||||
android:layout_gravity="top"
|
android:id="@+id/location_name_label"
|
||||||
android:maxLines="1"/>
|
android:layout_gravity="top"
|
||||||
|
android:maxLines="1"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="15dp"
|
||||||
|
android:layout_marginLeft="88dp"
|
||||||
|
android:layout_marginTop="52dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:textColor="#999999"
|
||||||
|
android:id="@+id/location_distance_label"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:maxLines="1"/>
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="15dp"
|
|
||||||
android:layout_marginLeft="88dp"
|
|
||||||
android:layout_marginTop="52dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:textColor="#999999"
|
|
||||||
android:id="@+id/location_distance_label"
|
|
||||||
android:layout_gravity="top"
|
|
||||||
android:maxLines="1"/>
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -14,7 +14,6 @@
|
|||||||
android:indeterminateDuration="1200"
|
android:indeterminateDuration="1200"
|
||||||
android:indeterminateOnly="true"
|
android:indeterminateOnly="true"
|
||||||
android:layout_gravity="center_vertical|left"
|
android:layout_gravity="center_vertical|left"
|
||||||
android:visibility="visible"
|
|
||||||
android:layout_marginLeft="12dp"/>
|
android:layout_marginLeft="12dp"/>
|
||||||
|
|
||||||
<ImageView android:layout_height="wrap_content"
|
<ImageView android:layout_height="wrap_content"
|
||||||
|
@ -5,4 +5,5 @@
|
|||||||
<color name="gallery_background_color">#ff000000</color>
|
<color name="gallery_background_color">#ff000000</color>
|
||||||
<color name="settings_background_color">#ffffffff</color>
|
<color name="settings_background_color">#ffffffff</color>
|
||||||
<color name="divider">#dcdcdc</color>
|
<color name="divider">#dcdcdc</color>
|
||||||
|
<color name="header">#ff54759e</color>
|
||||||
</resources>
|
</resources>
|
@ -269,7 +269,7 @@
|
|||||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||||
<string name="SortBy">Sort By</string>
|
<string name="SortBy">Sort By</string>
|
||||||
<string name="ImportContacts">Import Contacts</string>
|
<string name="ImportContacts">Import Contacts</string>
|
||||||
<string name="WiFiOnly">via WiFi only</string>
|
<string name="WiFiOnly">Via WiFi only</string>
|
||||||
<string name="SortFirstName">First name</string>
|
<string name="SortFirstName">First name</string>
|
||||||
<string name="SortLastName">Last name</string>
|
<string name="SortLastName">Last name</string>
|
||||||
|
|
||||||
|
@ -3,21 +3,16 @@
|
|||||||
|
|
||||||
<!--THEMES-->
|
<!--THEMES-->
|
||||||
|
|
||||||
<style name="Theme.TMessages.Start" parent="Theme.AppCompat.Light">
|
<style name="Theme.TMessages.Start" parent="@android:style/Theme.Holo.Light">
|
||||||
<item name="android:actionBarStyle">@style/ActionBar.Transparent.TMessages.Start</item>
|
<item name="android:actionBarStyle">@style/ActionBar.Transparent.TMessages.Start</item>
|
||||||
<item name="android:colorBackground">@android:color/white</item>
|
<item name="android:colorBackground">@android:color/white</item>
|
||||||
<item name="android:windowBackground">@android:color/white</item>
|
<item name="android:windowBackground">@android:color/white</item>
|
||||||
<item name="android:windowContentOverlay">@drawable/shadow</item>
|
<item name="android:windowContentOverlay">@drawable/shadow</item>
|
||||||
|
|
||||||
<item name="actionBarStyle">@style/ActionBar.Transparent.TMessages</item>
|
|
||||||
<item name="windowActionBarOverlay">false</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.TMessages" parent="Theme.AppCompat.Light">
|
<style name="Theme.TMessages" parent="@android:style/Theme.Holo.Light">
|
||||||
<item name="android:actionBarStyle">@style/ActionBar.Transparent.TMessages</item>
|
<item name="android:windowActionBar">false</item>
|
||||||
<item name="android:actionOverflowButtonStyle">@style/ActionBar.Transparent.TMessages.ActionButtonOverflow</item>
|
<item name="android:windowNoTitle">true</item>
|
||||||
<item name="android:homeAsUpIndicator">@drawable/ab_icon_up_messages</item>
|
|
||||||
<item name="android:popupMenuStyle">@style/ActionBar.Transparent.TMessages.Popup</item>
|
|
||||||
<item name="android:windowActionBarOverlay">false</item>
|
<item name="android:windowActionBarOverlay">false</item>
|
||||||
<item name="android:colorBackground">@android:color/white</item>
|
<item name="android:colorBackground">@android:color/white</item>
|
||||||
<item name="android:windowBackground">@android:color/white</item>
|
<item name="android:windowBackground">@android:color/white</item>
|
||||||
@ -25,17 +20,7 @@
|
|||||||
<item name="android:listViewStyle">@style/Theme.TMessages.ListView</item>
|
<item name="android:listViewStyle">@style/Theme.TMessages.ListView</item>
|
||||||
<item name="android:listChoiceBackgroundIndicator">@drawable/list_selector</item>
|
<item name="android:listChoiceBackgroundIndicator">@drawable/list_selector</item>
|
||||||
<item name="android:editTextStyle">@style/Theme.TMessages.EditText</item>
|
<item name="android:editTextStyle">@style/Theme.TMessages.EditText</item>
|
||||||
<item name="android:windowContentOverlay">@drawable/shadow</item>
|
|
||||||
<item name="android:actionBarItemBackground">@drawable/bar_selector</item>
|
<item name="android:actionBarItemBackground">@drawable/bar_selector</item>
|
||||||
<item name="searchViewSearchIcon">@android:color/transparent</item>
|
|
||||||
|
|
||||||
<item name="actionBarStyle">@style/ActionBar.Transparent.TMessages</item>
|
|
||||||
<item name="actionOverflowButtonStyle">@style/ActionBar.Transparent.TMessages.ActionButtonOverflow</item>
|
|
||||||
<item name="homeAsUpIndicator">@drawable/ab_icon_up_messages</item>
|
|
||||||
<item name="popupMenuStyle">@style/ActionBar.Transparent.TMessages.Popup</item>
|
|
||||||
<item name="windowActionBarOverlay">false</item>
|
|
||||||
<item name="listChoiceBackgroundIndicator">@drawable/list_selector</item>
|
|
||||||
<item name="actionBarItemBackground">@drawable/bar_selector</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.TMessages.Gallery" parent="Theme.AppCompat">
|
<style name="Theme.TMessages.Gallery" parent="Theme.AppCompat">
|
||||||
@ -60,26 +45,14 @@
|
|||||||
|
|
||||||
<!--ACTION BAR-->
|
<!--ACTION BAR-->
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.TMessages" parent="Widget.AppCompat.ActionBar">
|
<style name="ActionBar.Transparent.TMessages.Start" parent="android:style/Widget.Holo.Light.ActionBar">
|
||||||
<item name="android:background">@drawable/header</item>
|
<item name="android:background">@color/header</item>
|
||||||
<item name="android:logo">@drawable/ic_launcher</item>
|
|
||||||
<item name="android:titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
|
||||||
<item name="android:subtitleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Subtitle</item>
|
|
||||||
|
|
||||||
<item name="background">@drawable/header</item>
|
|
||||||
<item name="logo">@drawable/ic_launcher</item>
|
|
||||||
<item name="titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
|
||||||
<item name="subtitleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Subtitle</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.TMessages.Start" parent="Widget.AppCompat.ActionBar">
|
|
||||||
<item name="android:background">@drawable/header</item>
|
|
||||||
<item name="android:logo">@drawable/transparent</item>
|
<item name="android:logo">@drawable/transparent</item>
|
||||||
<item name="android:titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
<item name="android:titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
||||||
<item name="android:subtitleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Subtitle</item>
|
<item name="android:subtitleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Subtitle</item>
|
||||||
<item name="android:title">""</item>
|
<item name="android:title">""</item>
|
||||||
|
|
||||||
<item name="background">@drawable/header</item>
|
<item name="background">@color/header</item>
|
||||||
<item name="logo">@drawable/transparent</item>
|
<item name="logo">@drawable/transparent</item>
|
||||||
<item name="title">""</item>
|
<item name="title">""</item>
|
||||||
<item name="titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
<item name="titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
||||||
@ -101,19 +74,10 @@
|
|||||||
<item name="android:textSize">18sp</item>
|
<item name="android:textSize">18sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.TMessages.ActionButtonOverflow" parent="Widget.AppCompat.ActionButton.Overflow">
|
|
||||||
<item name="android:src">@drawable/ic_ab_other</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.TMessages.Gallery.ActionButtonOverflow" parent="Widget.AppCompat.ActionButton.Overflow">
|
<style name="ActionBar.Transparent.TMessages.Gallery.ActionButtonOverflow" parent="Widget.AppCompat.ActionButton.Overflow">
|
||||||
<item name="android:src">@drawable/ic_ab_other_white</item>
|
<item name="android:src">@drawable/ic_ab_other_white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.TMessages.Popup" parent="Widget.AppCompat.Light.ListPopupWindow">
|
|
||||||
<item name="android:popupBackground">@drawable/popup_fixed</item>
|
|
||||||
<item name="android:dropDownSelector">@drawable/list_selector</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="ActionBar.Transparent.TMessages.Gallery.Title" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
|
<style name="ActionBar.Transparent.TMessages.Gallery.Title" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
|
||||||
<item name="android:textColor">#ffffffff</item>
|
<item name="android:textColor">#ffffffff</item>
|
||||||
</style>
|
</style>
|
||||||
|