From cdb39ac30fe03ea8740573664ba155d27bab7914 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Wed, 4 Jun 2014 23:27:43 +0400 Subject: [PATCH] Ask confirmation when starting secret chat and sharing contact info Thanks to https://github.com/DrKLO/Telegram/pull/401 --- TMessagesProj/build.gradle | 2 +- .../java/org/telegram/ui/ChatActivity.java | 23 ++++++++++++++----- .../org/telegram/ui/UserProfileActivity.java | 14 +++++++++-- .../ui/Views/ActionBar/ActionBarActivity.java | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 192c82383..1596b9c1e 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -82,7 +82,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 237 + versionCode 238 versionName "1.4.15" } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 239700f5b..10d52abbc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -2566,15 +2566,26 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa topPanel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - MessagesController.getInstance().hidenAddToContacts.put(currentUser.id, currentUser); - topPanel.setVisibility(View.GONE); - MessagesController.getInstance().sendMessage(UserConfig.currentUser, dialog_id); - chatListView.post(new Runnable() { + 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 run() { - chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); + public void onClick(DialogInterface dialogInterface, int i) { + MessagesController.getInstance().hidenAddToContacts.put(currentUser.id, currentUser); + topPanel.setVisibility(View.GONE); + MessagesController.getInstance().sendMessage(UserConfig.currentUser, dialog_id); + chatListView.post(new Runnable() { + @Override + public void run() { + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); + } + }); } }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + visibleDialog = builder.show(); + visibleDialog.setCanceledOnTouchOutside(true); } }); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index a4c2052d3..a6e356d52 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -211,8 +211,18 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen startSecretButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - creatingChat = true; - MessagesController.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().users.get(user_id)); + 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) { + creatingChat = true; + MessagesController.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().users.get(user_id)); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + builder.show().setCanceledOnTouchOutside(true); } }); if (dialog_id == 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java index 191664c18..81365257a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java @@ -326,7 +326,7 @@ public class ActionBarActivity extends Activity { }); velocityTracker.recycle(); velocityTracker = null; - } else if (ev == null) { + } else if (ev == null || ev != null && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP)) { maybeStartTracking = false; startedTracking = false; if (velocityTracker != null) {