2013-10-25 17:19:00 +02:00
|
|
|
/*
|
2015-10-29 18:10:07 +01:00
|
|
|
* This is the source code of Telegram for Android v. 3.x.x.
|
2013-10-25 17:19:00 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
2016-01-11 18:19:48 +01:00
|
|
|
* Copyright Nikolai Kudashov, 2013-2016.
|
2013-10-25 17:19:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.annotation.TargetApi;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.app.Activity;
|
2015-05-03 13:48:36 +02:00
|
|
|
import android.app.AlertDialog;
|
2014-12-01 18:56:31 +01:00
|
|
|
import android.app.ProgressDialog;
|
2014-03-22 23:31:55 +01:00
|
|
|
import android.content.ContentResolver;
|
2014-12-01 18:56:31 +01:00
|
|
|
import android.content.DialogInterface;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2014-09-25 05:54:35 +02:00
|
|
|
import android.content.res.Configuration;
|
2014-03-04 20:29:32 +01:00
|
|
|
import android.database.Cursor;
|
2014-11-07 11:23:17 +01:00
|
|
|
import android.graphics.Point;
|
2016-10-11 13:57:01 +02:00
|
|
|
import android.graphics.Shader;
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
2014-03-04 20:29:32 +01:00
|
|
|
import android.net.Uri;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.os.Build;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.os.Bundle;
|
2014-03-04 20:29:32 +01:00
|
|
|
import android.os.Parcelable;
|
2014-03-22 23:31:55 +01:00
|
|
|
import android.provider.ContactsContract;
|
2015-09-24 22:52:02 +02:00
|
|
|
import android.support.annotation.NonNull;
|
2016-06-24 12:27:15 +02:00
|
|
|
import android.text.TextUtils;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.view.ActionMode;
|
2014-10-01 21:55:24 +02:00
|
|
|
import android.view.KeyEvent;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.view.MotionEvent;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.View;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
import android.view.Window;
|
2014-11-17 03:44:57 +01:00
|
|
|
import android.view.WindowManager;
|
2014-11-07 21:10:12 +01:00
|
|
|
import android.widget.AbsListView;
|
|
|
|
import android.widget.AdapterView;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.widget.FrameLayout;
|
2014-11-07 21:10:12 +01:00
|
|
|
import android.widget.ListView;
|
2014-09-24 04:17:27 +02:00
|
|
|
import android.widget.RelativeLayout;
|
2014-03-04 20:29:32 +01:00
|
|
|
import android.widget.Toast;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2014-03-22 23:31:55 +01:00
|
|
|
import org.telegram.PhoneFormat.PhoneFormat;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.ChatObject;
|
|
|
|
import org.telegram.messenger.ContactsController;
|
2015-10-29 18:10:07 +01:00
|
|
|
import org.telegram.messenger.ImageLoader;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.messenger.MessageObject;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
import org.telegram.messenger.MessagesStorage;
|
|
|
|
import org.telegram.messenger.NativeCrashManager;
|
|
|
|
import org.telegram.messenger.SendMessagesHelper;
|
|
|
|
import org.telegram.messenger.UserObject;
|
2016-03-06 02:49:31 +01:00
|
|
|
import org.telegram.messenger.Utilities;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2013-12-20 20:25:49 +01:00
|
|
|
import org.telegram.messenger.FileLog;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.messenger.R;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.messenger.browser.Browser;
|
2016-06-24 12:27:15 +02:00
|
|
|
import org.telegram.messenger.query.DraftQuery;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.tgnet.ConnectionsManager;
|
|
|
|
import org.telegram.tgnet.RequestDelegate;
|
|
|
|
import org.telegram.tgnet.TLObject;
|
|
|
|
import org.telegram.tgnet.TLRPC;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.messenger.UserConfig;
|
2014-11-07 21:10:12 +01:00
|
|
|
import org.telegram.ui.Adapters.DrawerLayoutAdapter;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.ActionBarLayout;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
|
|
import org.telegram.ui.ActionBar.DrawerLayoutContainer;
|
2016-10-11 13:57:01 +02:00
|
|
|
import org.telegram.ui.Components.JoinGroupAlert;
|
2015-05-03 13:48:36 +02:00
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
2015-02-26 02:32:51 +01:00
|
|
|
import org.telegram.ui.Components.PasscodeView;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.ui.Components.StickersAlert;
|
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-03-22 23:31:55 +01:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
2014-03-04 20:29:32 +01:00
|
|
|
import java.util.ArrayList;
|
2016-04-22 15:49:00 +02:00
|
|
|
import java.util.HashMap;
|
2016-03-06 02:49:31 +01:00
|
|
|
import java.util.List;
|
2014-04-05 01:00:38 +02:00
|
|
|
import java.util.Map;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate {
|
2015-06-29 19:12:11 +02:00
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
private boolean finished;
|
|
|
|
private String videoPath;
|
|
|
|
private String sendingText;
|
|
|
|
private ArrayList<Uri> photoPathsArray;
|
|
|
|
private ArrayList<String> documentsPathsArray;
|
2014-11-21 01:14:44 +01:00
|
|
|
private ArrayList<Uri> documentsUrisArray;
|
|
|
|
private String documentsMimeType;
|
2014-11-17 03:44:57 +01:00
|
|
|
private ArrayList<String> documentsOriginalPathsArray;
|
|
|
|
private ArrayList<TLRPC.User> contactsToSend;
|
2013-10-25 17:19:00 +02:00
|
|
|
private int currentConnectionState;
|
2015-01-02 23:15:07 +01:00
|
|
|
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<>();
|
|
|
|
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<>();
|
|
|
|
private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<>();
|
2015-11-26 22:04:02 +01:00
|
|
|
private ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener;
|
2014-09-24 04:17:27 +02:00
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
private ActionBarLayout actionBarLayout;
|
|
|
|
private ActionBarLayout layersActionBarLayout;
|
|
|
|
private ActionBarLayout rightActionBarLayout;
|
|
|
|
private FrameLayout shadowTablet;
|
|
|
|
private FrameLayout shadowTabletSide;
|
2016-10-11 13:57:01 +02:00
|
|
|
private View backgroundTablet;
|
2015-05-03 13:48:36 +02:00
|
|
|
protected DrawerLayoutContainer drawerLayoutContainer;
|
2014-11-17 03:44:57 +01:00
|
|
|
private DrawerLayoutAdapter drawerLayoutAdapter;
|
2015-02-26 02:32:51 +01:00
|
|
|
private PasscodeView passcodeView;
|
2015-05-03 13:48:36 +02:00
|
|
|
private AlertDialog visibleDialog;
|
2016-10-11 13:57:01 +02:00
|
|
|
private ListView listView;
|
2015-02-26 02:32:51 +01:00
|
|
|
|
|
|
|
private Intent passcodeSaveIntent;
|
|
|
|
private boolean passcodeSaveIntentIsNew;
|
|
|
|
private boolean passcodeSaveIntentIsRestore;
|
2014-11-07 21:10:12 +01:00
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
private boolean tabletFullSize;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
private Runnable lockRunnable;
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2014-03-22 23:31:55 +01:00
|
|
|
ApplicationLoader.postInitApplication();
|
2015-09-24 22:52:02 +02:00
|
|
|
NativeCrashManager.handleDumpFiles(this);
|
2016-10-11 13:57:01 +02:00
|
|
|
AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
|
2014-03-22 23:31:55 +01:00
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!UserConfig.isClientActivated()) {
|
2014-03-04 20:29:32 +01:00
|
|
|
Intent intent = getIntent();
|
2014-03-24 22:10:35 +01:00
|
|
|
if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
|
2014-09-24 04:17:27 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
2014-03-04 20:29:32 +01:00
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
if (intent != null && !intent.getBooleanExtra("fromIntro", false)) {
|
2016-03-16 13:26:32 +01:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", MODE_PRIVATE);
|
2014-06-04 01:31:48 +02:00
|
|
|
Map<String, ?> state = preferences.getAll();
|
|
|
|
if (state.isEmpty()) {
|
|
|
|
Intent intent2 = new Intent(this, IntroActivity.class);
|
|
|
|
startActivity(intent2);
|
2014-09-24 04:17:27 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
2014-06-04 01:31:48 +02:00
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
2014-04-05 01:00:38 +02:00
|
|
|
}
|
2014-03-04 20:29:32 +01:00
|
|
|
}
|
2013-12-20 20:25:49 +01:00
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
|
|
setTheme(R.style.Theme_TMessages);
|
|
|
|
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
|
|
AndroidUtilities.isInMultiwindow = isInMultiWindowMode();
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
Theme.loadRecources(this);
|
2014-06-04 01:31:48 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) {
|
|
|
|
UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime();
|
|
|
|
}
|
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
|
|
|
if (resourceId > 0) {
|
|
|
|
AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
|
|
|
}
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout = new ActionBarLayout(this);
|
2014-11-17 03:44:57 +01:00
|
|
|
|
|
|
|
drawerLayoutContainer = new DrawerLayoutContainer(this);
|
|
|
|
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
2014-11-17 03:44:57 +01:00
|
|
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
RelativeLayout launchLayout = new RelativeLayout(this) {
|
|
|
|
|
|
|
|
private boolean inLayout;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void requestLayout() {
|
|
|
|
if (inLayout) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
super.requestLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
inLayout = true;
|
|
|
|
int width = MeasureSpec.getSize(widthMeasureSpec);
|
|
|
|
int height = MeasureSpec.getSize(heightMeasureSpec);
|
|
|
|
setMeasuredDimension(width, height);
|
|
|
|
|
|
|
|
if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)) {
|
|
|
|
tabletFullSize = false;
|
|
|
|
int leftWidth = width / 100 * 35;
|
|
|
|
if (leftWidth < AndroidUtilities.dp(320)) {
|
|
|
|
leftWidth = AndroidUtilities.dp(320);
|
|
|
|
}
|
|
|
|
actionBarLayout.measure(MeasureSpec.makeMeasureSpec(leftWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
|
|
|
shadowTabletSide.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
|
|
|
rightActionBarLayout.measure(MeasureSpec.makeMeasureSpec(width - leftWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
|
|
|
} else {
|
|
|
|
tabletFullSize = true;
|
|
|
|
actionBarLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
backgroundTablet.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
|
|
|
shadowTablet.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
|
|
|
layersActionBarLayout.measure(MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(530), width), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(528) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0), height), MeasureSpec.EXACTLY));
|
|
|
|
|
|
|
|
inLayout = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
int width = r - l;
|
|
|
|
int height = b - t;
|
|
|
|
|
|
|
|
if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)) {
|
|
|
|
int leftWidth = width / 100 * 35;
|
|
|
|
if (leftWidth < AndroidUtilities.dp(320)) {
|
|
|
|
leftWidth = AndroidUtilities.dp(320);
|
|
|
|
}
|
|
|
|
shadowTabletSide.layout(leftWidth, 0, leftWidth + shadowTabletSide.getMeasuredWidth(), shadowTabletSide.getMeasuredHeight());
|
|
|
|
actionBarLayout.layout(0, 0, actionBarLayout.getMeasuredWidth(), actionBarLayout.getMeasuredHeight());
|
|
|
|
rightActionBarLayout.layout(leftWidth, 0, leftWidth + rightActionBarLayout.getMeasuredWidth(), rightActionBarLayout.getMeasuredHeight());
|
|
|
|
} else {
|
|
|
|
actionBarLayout.layout(0, 0, actionBarLayout.getMeasuredWidth(), actionBarLayout.getMeasuredHeight());
|
|
|
|
}
|
|
|
|
int x = (width - layersActionBarLayout.getMeasuredWidth()) / 2;
|
|
|
|
int y = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + (height - layersActionBarLayout.getMeasuredHeight()) / 2;
|
|
|
|
layersActionBarLayout.layout(x, y, x + layersActionBarLayout.getMeasuredWidth(), y + layersActionBarLayout.getMeasuredHeight());
|
|
|
|
backgroundTablet.layout(0, 0, backgroundTablet.getMeasuredWidth(), backgroundTablet.getMeasuredHeight());
|
|
|
|
shadowTablet.layout(0, 0, shadowTablet.getMeasuredWidth(), shadowTablet.getMeasuredHeight());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
drawerLayoutContainer.addView(launchLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
|
|
|
backgroundTablet = new View(this);
|
|
|
|
BitmapDrawable drawable = (BitmapDrawable) getResources().getDrawable(R.drawable.catstile);
|
|
|
|
drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
|
|
|
|
backgroundTablet.setBackgroundDrawable(drawable);
|
|
|
|
launchLayout.addView(backgroundTablet, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
2014-11-17 03:44:57 +01:00
|
|
|
|
|
|
|
launchLayout.addView(actionBarLayout);
|
2014-09-24 04:17:27 +02:00
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
rightActionBarLayout = new ActionBarLayout(this);
|
|
|
|
rightActionBarLayout.init(rightFragmentsStack);
|
|
|
|
rightActionBarLayout.setDelegate(this);
|
2016-10-11 13:57:01 +02:00
|
|
|
launchLayout.addView(rightActionBarLayout);
|
2014-11-17 03:44:57 +01:00
|
|
|
|
|
|
|
shadowTabletSide = new FrameLayout(this);
|
|
|
|
shadowTabletSide.setBackgroundColor(0x40295274);
|
|
|
|
launchLayout.addView(shadowTabletSide);
|
|
|
|
|
|
|
|
shadowTablet = new FrameLayout(this);
|
2016-10-11 13:57:01 +02:00
|
|
|
shadowTablet.setVisibility(layerFragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
|
2014-11-17 03:44:57 +01:00
|
|
|
shadowTablet.setBackgroundColor(0x7F000000);
|
|
|
|
launchLayout.addView(shadowTablet);
|
2014-09-24 04:17:27 +02:00
|
|
|
shadowTablet.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
2014-09-28 15:37:26 +02:00
|
|
|
if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
|
|
|
|
float x = event.getX();
|
|
|
|
float y = event.getY();
|
|
|
|
int location[] = new int[2];
|
|
|
|
layersActionBarLayout.getLocationOnScreen(location);
|
|
|
|
int viewX = location[0];
|
|
|
|
int viewY = location[1];
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
|
2014-09-28 15:37:26 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
layersActionBarLayout.closeLastFragment(true);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
shadowTablet.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
layersActionBarLayout = new ActionBarLayout(this);
|
2014-11-17 03:44:57 +01:00
|
|
|
layersActionBarLayout.setRemoveActionBarExtraHeight(true);
|
2014-09-24 04:17:27 +02:00
|
|
|
layersActionBarLayout.setBackgroundView(shadowTablet);
|
|
|
|
layersActionBarLayout.setUseAlphaAnimations(true);
|
|
|
|
layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
|
|
|
|
layersActionBarLayout.init(layerFragmentsStack);
|
|
|
|
layersActionBarLayout.setDelegate(this);
|
2014-11-17 03:44:57 +01:00
|
|
|
layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
|
2016-10-11 13:57:01 +02:00
|
|
|
layersActionBarLayout.setVisibility(layerFragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
|
|
|
|
launchLayout.addView(layersActionBarLayout);
|
2014-11-17 03:44:57 +01:00
|
|
|
} else {
|
|
|
|
drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
listView = new ListView(this) {
|
2015-10-29 18:10:07 +01:00
|
|
|
@Override
|
|
|
|
public boolean hasOverlappingRendering() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
listView.setBackgroundColor(0xffffffff);
|
2015-07-22 20:56:37 +02:00
|
|
|
listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this));
|
2014-11-17 03:44:57 +01:00
|
|
|
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
|
|
|
|
listView.setDivider(null);
|
|
|
|
listView.setDividerHeight(0);
|
|
|
|
listView.setVerticalScrollBarEnabled(false);
|
2015-10-29 18:10:07 +01:00
|
|
|
drawerLayoutContainer.setDrawerLayout(listView);
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
|
|
|
Point screenSize = AndroidUtilities.getRealScreenSize();
|
2016-06-24 12:27:15 +02:00
|
|
|
layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(AndroidUtilities.dp(320), Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56));
|
2015-10-29 18:10:07 +01:00
|
|
|
layoutParams.height = LayoutHelper.MATCH_PARENT;
|
|
|
|
listView.setLayoutParams(layoutParams);
|
2014-11-17 03:44:57 +01:00
|
|
|
|
|
|
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (position == 0) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", UserConfig.getClientUserId());
|
|
|
|
presentFragment(new ChatActivity(args));
|
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 2) {
|
2015-02-27 20:57:58 +01:00
|
|
|
if (!MessagesController.isFeatureEnabled("chat_create", actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1))) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
presentFragment(new GroupCreateActivity());
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 3) {
|
2014-09-24 04:17:27 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlyUsers", true);
|
|
|
|
args.putBoolean("destroyAfterSelect", true);
|
|
|
|
args.putBoolean("createSecretChat", true);
|
2016-03-16 13:26:32 +01:00
|
|
|
args.putBoolean("allowBots", false);
|
2014-09-24 04:17:27 +02:00
|
|
|
presentFragment(new ContactsActivity(args));
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 4) {
|
2015-02-27 20:57:58 +01:00
|
|
|
if (!MessagesController.isFeatureEnabled("broadcast_create", actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1))) {
|
|
|
|
return;
|
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
|
|
if (preferences.getBoolean("channel_intro", false)) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("step", 0);
|
|
|
|
presentFragment(new ChannelCreateActivity(args));
|
|
|
|
} else {
|
|
|
|
presentFragment(new ChannelIntroActivity());
|
|
|
|
preferences.edit().putBoolean("channel_intro", true).commit();
|
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 6) {
|
2014-09-24 04:17:27 +02:00
|
|
|
presentFragment(new ContactsActivity(null));
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 7) {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
|
|
|
intent.setType("text/plain");
|
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText());
|
2015-02-26 02:32:51 +01:00
|
|
|
startActivityForResult(Intent.createChooser(intent, LocaleController.getString("InviteFriends", R.string.InviteFriends)), 500);
|
2014-11-17 03:44:57 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 8) {
|
2014-09-24 04:17:27 +02:00
|
|
|
presentFragment(new SettingsActivity());
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (position == 9) {
|
2016-04-22 15:49:00 +02:00
|
|
|
Browser.openUrl(LaunchActivity.this, LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl));
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
2014-11-07 21:10:12 +01:00
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
}
|
|
|
|
});
|
2014-11-07 21:10:12 +01:00
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
|
|
|
|
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.init(mainFragmentsStack);
|
|
|
|
actionBarLayout.setDelegate(this);
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
ApplicationLoader.loadWallpaper();
|
|
|
|
|
|
|
|
passcodeView = new PasscodeView(this);
|
|
|
|
drawerLayoutContainer.addView(passcodeView);
|
|
|
|
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams();
|
2015-05-03 13:48:36 +02:00
|
|
|
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
|
|
|
layoutParams1.height = LayoutHelper.MATCH_PARENT;
|
2015-02-26 02:32:51 +01:00
|
|
|
passcodeView.setLayoutParams(layoutParams1);
|
|
|
|
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
|
2014-07-03 00:39:05 +02:00
|
|
|
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
|
2014-06-04 01:31:48 +02:00
|
|
|
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
|
2014-11-17 03:44:57 +01:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
|
2015-12-09 19:27:52 +01:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.needShowAlert);
|
2016-04-22 15:49:00 +02:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
|
2016-10-11 13:57:01 +02:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!UserConfig.isClientActivated()) {
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.addFragmentToStack(new LoginActivity());
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
2014-06-04 01:31:48 +02:00
|
|
|
} else {
|
2015-07-22 20:56:37 +02:00
|
|
|
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
2015-04-09 20:00:14 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2014-03-26 21:16:28 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
if (savedInstanceState != null) {
|
|
|
|
String fragmentName = savedInstanceState.getString("fragment");
|
|
|
|
if (fragmentName != null) {
|
|
|
|
Bundle args = savedInstanceState.getBundle("args");
|
2015-01-02 23:15:07 +01:00
|
|
|
switch (fragmentName) {
|
|
|
|
case "chat":
|
|
|
|
if (args != null) {
|
|
|
|
ChatActivity chat = new ChatActivity(args);
|
|
|
|
if (actionBarLayout.addFragmentToStack(chat)) {
|
|
|
|
chat.restoreSelfArgs(savedInstanceState);
|
|
|
|
}
|
2014-03-26 21:16:28 +01:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
break;
|
|
|
|
case "settings": {
|
|
|
|
SettingsActivity settings = new SettingsActivity();
|
|
|
|
actionBarLayout.addFragmentToStack(settings);
|
|
|
|
settings.restoreSelfArgs(savedInstanceState);
|
|
|
|
break;
|
2014-03-26 21:16:28 +01:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
case "group":
|
|
|
|
if (args != null) {
|
|
|
|
GroupCreateFinalActivity group = new GroupCreateFinalActivity(args);
|
|
|
|
if (actionBarLayout.addFragmentToStack(group)) {
|
|
|
|
group.restoreSelfArgs(savedInstanceState);
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
break;
|
2015-09-24 22:52:02 +02:00
|
|
|
case "channel":
|
|
|
|
if (args != null) {
|
|
|
|
ChannelCreateActivity channel = new ChannelCreateActivity(args);
|
|
|
|
if (actionBarLayout.addFragmentToStack(channel)) {
|
|
|
|
channel.restoreSelfArgs(savedInstanceState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "edit":
|
|
|
|
if (args != null) {
|
|
|
|
ChannelEditActivity channel = new ChannelEditActivity(args);
|
|
|
|
if (actionBarLayout.addFragmentToStack(channel)) {
|
|
|
|
channel.restoreSelfArgs(savedInstanceState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-01-02 23:15:07 +01:00
|
|
|
case "chat_profile":
|
|
|
|
if (args != null) {
|
|
|
|
ProfileActivity profile = new ProfileActivity(args);
|
|
|
|
if (actionBarLayout.addFragmentToStack(profile)) {
|
|
|
|
profile.restoreSelfArgs(savedInstanceState);
|
|
|
|
}
|
2014-03-26 21:16:28 +01:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
break;
|
|
|
|
case "wallpapers": {
|
|
|
|
WallpapersActivity settings = new WallpapersActivity();
|
|
|
|
actionBarLayout.addFragmentToStack(settings);
|
|
|
|
settings.restoreSelfArgs(savedInstanceState);
|
|
|
|
break;
|
2014-03-26 21:16:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2014-11-18 13:37:11 +01:00
|
|
|
} else {
|
2015-05-21 23:27:27 +02:00
|
|
|
boolean allowOpen = true;
|
2014-11-18 13:37:11 +01:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
2014-12-01 18:56:31 +01:00
|
|
|
allowOpen = actionBarLayout.fragmentsStack.size() <= 1 && layersActionBarLayout.fragmentsStack.isEmpty();
|
2015-05-21 23:27:27 +02:00
|
|
|
if (layersActionBarLayout.fragmentsStack.size() == 1 && layersActionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
|
|
|
|
allowOpen = false;
|
|
|
|
}
|
2014-11-18 13:37:11 +01:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
if (actionBarLayout.fragmentsStack.size() == 1 && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
|
2014-12-01 18:56:31 +01:00
|
|
|
allowOpen = false;
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
checkLayout();
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
handleIntent(getIntent(), false, savedInstanceState != null, false);
|
2015-11-26 22:04:02 +01:00
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
try {
|
|
|
|
String os1 = Build.DISPLAY;
|
|
|
|
String os2 = Build.USER;
|
|
|
|
if (os1 != null) {
|
|
|
|
os1 = os1.toLowerCase();
|
|
|
|
} else {
|
|
|
|
os1 = "";
|
|
|
|
}
|
|
|
|
if (os2 != null) {
|
|
|
|
os2 = os1.toLowerCase();
|
|
|
|
} else {
|
|
|
|
os2 = "";
|
|
|
|
}
|
|
|
|
if (os1.contains("flyme") || os2.contains("flyme")) {
|
|
|
|
AndroidUtilities.incorrectDisplaySizeFix = true;
|
|
|
|
final View view = getWindow().getDecorView().getRootView();
|
|
|
|
view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
int height = view.getMeasuredHeight();
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
height -= AndroidUtilities.statusBarHeight;
|
|
|
|
}
|
|
|
|
if (height > AndroidUtilities.dp(100) && height < AndroidUtilities.displaySize.y && height + AndroidUtilities.dp(100) > AndroidUtilities.displaySize.y) {
|
|
|
|
AndroidUtilities.displaySize.y = height;
|
|
|
|
FileLog.e("tmessages", "fix display size y to " + AndroidUtilities.displaySize.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkLayout() {
|
|
|
|
if (!AndroidUtilities.isTablet()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)) {
|
|
|
|
tabletFullSize = false;
|
|
|
|
if (actionBarLayout.fragmentsStack.size() >= 2) {
|
|
|
|
for (int a = 1; a < actionBarLayout.fragmentsStack.size(); a++) {
|
|
|
|
BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(a);
|
|
|
|
chatFragment.onPause();
|
|
|
|
actionBarLayout.fragmentsStack.remove(a);
|
|
|
|
rightActionBarLayout.fragmentsStack.add(chatFragment);
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
if (passcodeView.getVisibility() != View.VISIBLE) {
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
2015-11-26 22:04:02 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
rightActionBarLayout.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
|
|
|
|
backgroundTablet.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
|
|
|
|
shadowTabletSide.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
|
|
|
|
} else {
|
|
|
|
tabletFullSize = true;
|
|
|
|
if (!rightActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < rightActionBarLayout.fragmentsStack.size(); a++) {
|
|
|
|
BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(a);
|
|
|
|
chatFragment.onPause();
|
|
|
|
rightActionBarLayout.fragmentsStack.remove(a);
|
|
|
|
actionBarLayout.fragmentsStack.add(chatFragment);
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
if (passcodeView.getVisibility() != View.VISIBLE) {
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shadowTabletSide.setVisibility(View.GONE);
|
|
|
|
rightActionBarLayout.setVisibility(View.GONE);
|
|
|
|
backgroundTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
private void showPasscodeActivity() {
|
|
|
|
if (passcodeView == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
UserConfig.appLocked = true;
|
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
|
|
|
PhotoViewer.getInstance().closePhoto(false, true);
|
|
|
|
}
|
|
|
|
passcodeView.onShow();
|
|
|
|
UserConfig.isWaitingForPasscodeEnter = true;
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
2015-02-26 02:32:51 +01:00
|
|
|
passcodeView.setDelegate(new PasscodeView.PasscodeViewDelegate() {
|
|
|
|
@Override
|
|
|
|
public void didAcceptedPassword() {
|
|
|
|
UserConfig.isWaitingForPasscodeEnter = false;
|
|
|
|
if (passcodeSaveIntent != null) {
|
|
|
|
handleIntent(passcodeSaveIntent, passcodeSaveIntentIsNew, passcodeSaveIntentIsRestore, true);
|
|
|
|
passcodeSaveIntent = null;
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2015-02-26 02:32:51 +01:00
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
layersActionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
private class VcardData {
|
|
|
|
String name;
|
|
|
|
ArrayList<String> phones = new ArrayList<>();
|
|
|
|
}
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
private boolean handleIntent(Intent intent, boolean isNew, boolean restore, boolean fromPassword) {
|
|
|
|
int flags = intent.getFlags();
|
|
|
|
if (!fromPassword && (AndroidUtilities.needShowPasscode(true) || UserConfig.isWaitingForPasscodeEnter)) {
|
|
|
|
showPasscodeActivity();
|
|
|
|
passcodeSaveIntent = intent;
|
|
|
|
passcodeSaveIntentIsNew = isNew;
|
|
|
|
passcodeSaveIntentIsRestore = restore;
|
|
|
|
UserConfig.saveConfig(false);
|
|
|
|
} else {
|
|
|
|
boolean pushOpened = false;
|
|
|
|
|
|
|
|
Integer push_user_id = 0;
|
|
|
|
Integer push_chat_id = 0;
|
|
|
|
Integer push_enc_id = 0;
|
|
|
|
Integer open_settings = 0;
|
2015-10-29 18:10:07 +01:00
|
|
|
long dialogId = intent != null && intent.getExtras() != null ? intent.getExtras().getLong("dialogId", 0) : 0;
|
2015-02-26 02:32:51 +01:00
|
|
|
boolean showDialogsList = false;
|
2015-07-22 20:56:37 +02:00
|
|
|
boolean showPlayer = false;
|
2014-05-17 01:05:49 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
photoPathsArray = null;
|
|
|
|
videoPath = null;
|
|
|
|
sendingText = null;
|
|
|
|
documentsPathsArray = null;
|
|
|
|
documentsOriginalPathsArray = null;
|
|
|
|
documentsMimeType = null;
|
|
|
|
documentsUrisArray = null;
|
|
|
|
contactsToSend = null;
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
if (UserConfig.isClientActivated() && (flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
|
2015-02-26 02:32:51 +01:00
|
|
|
if (intent != null && intent.getAction() != null && !restore) {
|
|
|
|
if (Intent.ACTION_SEND.equals(intent.getAction())) {
|
|
|
|
boolean error = false;
|
|
|
|
String type = intent.getType();
|
2015-05-21 23:27:27 +02:00
|
|
|
if (type != null && type.equals(ContactsContract.Contacts.CONTENT_VCARD_TYPE)) {
|
2015-02-26 02:32:51 +01:00
|
|
|
try {
|
|
|
|
Uri uri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM);
|
|
|
|
if (uri != null) {
|
|
|
|
ContentResolver cr = getContentResolver();
|
|
|
|
InputStream stream = cr.openInputStream(uri);
|
2016-06-24 12:27:15 +02:00
|
|
|
ArrayList<VcardData> vcardDatas = new ArrayList<>();
|
|
|
|
VcardData currentData = null;
|
2015-02-26 02:32:51 +01:00
|
|
|
|
|
|
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
|
2015-05-21 23:27:27 +02:00
|
|
|
String line;
|
2015-02-26 02:32:51 +01:00
|
|
|
while ((line = bufferedReader.readLine()) != null) {
|
2016-06-24 12:27:15 +02:00
|
|
|
FileLog.e("tmessages", line);
|
2015-02-26 02:32:51 +01:00
|
|
|
String[] args = line.split(":");
|
|
|
|
if (args.length != 2) {
|
|
|
|
continue;
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
if (args[0].equals("BEGIN") && args[1].equals("VCARD")) {
|
|
|
|
vcardDatas.add(currentData = new VcardData());
|
|
|
|
} else if (args[0].equals("END") && args[1].equals("VCARD")) {
|
|
|
|
currentData = null;
|
|
|
|
}
|
|
|
|
if (currentData == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (args[0].startsWith("FN") || args[0].startsWith("ORG") && TextUtils.isEmpty(currentData.name)) {
|
|
|
|
String nameEncoding = null;
|
|
|
|
String nameCharset = null;
|
2015-02-26 02:32:51 +01:00
|
|
|
String[] params = args[0].split(";");
|
|
|
|
for (String param : params) {
|
|
|
|
String[] args2 = param.split("=");
|
|
|
|
if (args2.length != 2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (args2[0].equals("CHARSET")) {
|
|
|
|
nameCharset = args2[1];
|
|
|
|
} else if (args2[0].equals("ENCODING")) {
|
|
|
|
nameEncoding = args2[1];
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
currentData.name = args[1];
|
2015-02-26 02:32:51 +01:00
|
|
|
if (nameEncoding != null && nameEncoding.equalsIgnoreCase("QUOTED-PRINTABLE")) {
|
2016-06-24 12:27:15 +02:00
|
|
|
while (currentData.name.endsWith("=") && nameEncoding != null) {
|
|
|
|
currentData.name = currentData.name.substring(0, currentData.name.length() - 1);
|
2015-02-26 02:32:51 +01:00
|
|
|
line = bufferedReader.readLine();
|
|
|
|
if (line == null) {
|
|
|
|
break;
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
currentData.name += line;
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
byte[] bytes = AndroidUtilities.decodeQuotedPrintable(currentData.name.getBytes());
|
2015-02-26 02:32:51 +01:00
|
|
|
if (bytes != null && bytes.length != 0) {
|
|
|
|
String decodedName = new String(bytes, nameCharset);
|
|
|
|
if (decodedName != null) {
|
2016-06-24 12:27:15 +02:00
|
|
|
currentData.name = decodedName;
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (args[0].startsWith("TEL")) {
|
|
|
|
String phone = PhoneFormat.stripExceptNumbers(args[1], true);
|
|
|
|
if (phone.length() > 0) {
|
2016-06-24 12:27:15 +02:00
|
|
|
currentData.phones.add(phone);
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2015-02-27 20:57:58 +01:00
|
|
|
try {
|
|
|
|
bufferedReader.close();
|
|
|
|
stream.close();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
for (int a = 0; a < vcardDatas.size(); a++) {
|
|
|
|
VcardData vcardData = vcardDatas.get(a);
|
|
|
|
if (vcardData.name != null && !vcardData.phones.isEmpty()) {
|
|
|
|
if (contactsToSend == null) {
|
|
|
|
contactsToSend = new ArrayList<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int b = 0; b < vcardData.phones.size(); b++) {
|
|
|
|
String phone = vcardData.phones.get(b);
|
|
|
|
TLRPC.User user = new TLRPC.TL_userContact_old2();
|
|
|
|
user.phone = phone;
|
|
|
|
user.first_name = vcardData.name;
|
|
|
|
user.last_name = "";
|
|
|
|
user.id = 0;
|
|
|
|
contactsToSend.add(user);
|
|
|
|
}
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
} else {
|
2016-04-22 15:49:00 +02:00
|
|
|
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
|
|
|
|
if (text == null) {
|
|
|
|
CharSequence textSequence = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
|
|
|
|
if (textSequence != null) {
|
|
|
|
text = textSequence.toString();
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
if (text != null && text.length() != 0) {
|
|
|
|
if ((text.startsWith("http://") || text.startsWith("https://")) && subject != null && subject.length() != 0) {
|
|
|
|
text = subject + "\n" + text;
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
sendingText = text;
|
|
|
|
} else if (subject != null && subject.length() > 0) {
|
|
|
|
sendingText = subject;
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
Parcelable parcelable = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
|
|
|
if (parcelable != null) {
|
2015-05-21 23:27:27 +02:00
|
|
|
String path;
|
2015-02-26 02:32:51 +01:00
|
|
|
if (!(parcelable instanceof Uri)) {
|
|
|
|
parcelable = Uri.parse(parcelable.toString());
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
Uri uri = (Uri) parcelable;
|
2016-03-06 02:49:31 +01:00
|
|
|
if (uri != null) {
|
2016-05-25 23:49:47 +02:00
|
|
|
if (AndroidUtilities.isInternalUri(uri)) {
|
2016-04-22 15:49:00 +02:00
|
|
|
error = true;
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
if (!error) {
|
|
|
|
if (uri != null && (type != null && type.startsWith("image/") || uri.toString().toLowerCase().endsWith(".jpg"))) {
|
|
|
|
if (photoPathsArray == null) {
|
|
|
|
photoPathsArray = new ArrayList<>();
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
photoPathsArray.add(uri);
|
|
|
|
} else {
|
|
|
|
path = AndroidUtilities.getPath(uri);
|
|
|
|
if (path != null) {
|
|
|
|
if (path.startsWith("file:")) {
|
|
|
|
path = path.replace("file://", "");
|
|
|
|
}
|
|
|
|
if (type != null && type.startsWith("video/")) {
|
|
|
|
videoPath = path;
|
|
|
|
} else {
|
|
|
|
if (documentsPathsArray == null) {
|
|
|
|
documentsPathsArray = new ArrayList<>();
|
|
|
|
documentsOriginalPathsArray = new ArrayList<>();
|
|
|
|
}
|
|
|
|
documentsPathsArray.add(path);
|
|
|
|
documentsOriginalPathsArray.add(uri.toString());
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
2016-03-06 02:49:31 +01:00
|
|
|
if (documentsUrisArray == null) {
|
|
|
|
documentsUrisArray = new ArrayList<>();
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
documentsUrisArray.add(uri);
|
|
|
|
documentsMimeType = type;
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
} else if (sendingText == null) {
|
2014-05-17 01:05:49 +02:00
|
|
|
error = true;
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show();
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
} else if (intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
|
|
|
|
boolean error = false;
|
|
|
|
try {
|
|
|
|
ArrayList<Parcelable> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
|
|
|
String type = intent.getType();
|
2016-03-06 02:49:31 +01:00
|
|
|
if (uris != null) {
|
|
|
|
for (int a = 0; a < uris.size(); a++) {
|
|
|
|
Parcelable parcelable = uris.get(a);
|
|
|
|
if (!(parcelable instanceof Uri)) {
|
|
|
|
parcelable = Uri.parse(parcelable.toString());
|
|
|
|
}
|
|
|
|
Uri uri = (Uri) parcelable;
|
|
|
|
if (uri != null) {
|
2016-05-25 23:49:47 +02:00
|
|
|
if (AndroidUtilities.isInternalUri(uri)) {
|
2016-04-22 15:49:00 +02:00
|
|
|
uris.remove(a);
|
|
|
|
a--;
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (uris.isEmpty()) {
|
|
|
|
uris = null;
|
|
|
|
}
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
if (uris != null) {
|
|
|
|
if (type != null && type.startsWith("image/")) {
|
2016-03-06 02:49:31 +01:00
|
|
|
for (int a = 0; a < uris.size(); a++) {
|
|
|
|
Parcelable parcelable = uris.get(a);
|
2015-02-26 02:32:51 +01:00
|
|
|
if (!(parcelable instanceof Uri)) {
|
|
|
|
parcelable = Uri.parse(parcelable.toString());
|
|
|
|
}
|
|
|
|
Uri uri = (Uri) parcelable;
|
|
|
|
if (photoPathsArray == null) {
|
|
|
|
photoPathsArray = new ArrayList<>();
|
2015-01-02 23:15:07 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
photoPathsArray.add(uri);
|
2015-01-02 23:15:07 +01:00
|
|
|
}
|
2014-05-17 01:05:49 +02:00
|
|
|
} else {
|
2016-03-06 02:49:31 +01:00
|
|
|
for (int a = 0; a < uris.size(); a++) {
|
|
|
|
Parcelable parcelable = uris.get(a);
|
2015-02-26 02:32:51 +01:00
|
|
|
if (!(parcelable instanceof Uri)) {
|
|
|
|
parcelable = Uri.parse(parcelable.toString());
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
String path = AndroidUtilities.getPath((Uri) parcelable);
|
2015-02-26 02:32:51 +01:00
|
|
|
String originalPath = parcelable.toString();
|
|
|
|
if (originalPath == null) {
|
|
|
|
originalPath = path;
|
|
|
|
}
|
|
|
|
if (path != null) {
|
|
|
|
if (path.startsWith("file:")) {
|
|
|
|
path = path.replace("file://", "");
|
|
|
|
}
|
|
|
|
if (documentsPathsArray == null) {
|
|
|
|
documentsPathsArray = new ArrayList<>();
|
|
|
|
documentsOriginalPathsArray = new ArrayList<>();
|
|
|
|
}
|
|
|
|
documentsPathsArray.add(path);
|
|
|
|
documentsOriginalPathsArray.add(originalPath);
|
|
|
|
}
|
2014-06-20 02:18:13 +02:00
|
|
|
}
|
2014-04-05 19:11:44 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
|
|
|
error = true;
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
2015-01-02 23:15:07 +01:00
|
|
|
error = true;
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
|
|
|
Uri data = intent.getData();
|
|
|
|
if (data != null) {
|
|
|
|
String username = null;
|
2015-05-03 13:48:36 +02:00
|
|
|
String group = null;
|
2015-05-21 23:27:27 +02:00
|
|
|
String sticker = null;
|
2015-06-29 19:12:11 +02:00
|
|
|
String botUser = null;
|
|
|
|
String botChat = null;
|
2015-08-13 11:23:31 +02:00
|
|
|
String message = null;
|
2016-10-11 13:57:01 +02:00
|
|
|
String phone = null;
|
|
|
|
String game = null;
|
|
|
|
String phoneHash = null;
|
2016-03-06 02:49:31 +01:00
|
|
|
Integer messageId = null;
|
2015-10-29 18:10:07 +01:00
|
|
|
boolean hasUrl = false;
|
2015-02-26 02:32:51 +01:00
|
|
|
String scheme = data.getScheme();
|
|
|
|
if (scheme != null) {
|
|
|
|
if ((scheme.equals("http") || scheme.equals("https"))) {
|
|
|
|
String host = data.getHost().toLowerCase();
|
2016-03-16 13:26:32 +01:00
|
|
|
if (host.equals("telegram.me") || host.equals("telegram.dog")) {
|
2015-02-26 02:32:51 +01:00
|
|
|
String path = data.getPath();
|
2015-09-24 22:52:02 +02:00
|
|
|
if (path != null && path.length() > 1) {
|
2015-05-03 13:48:36 +02:00
|
|
|
path = path.substring(1);
|
|
|
|
if (path.startsWith("joinchat/")) {
|
|
|
|
group = path.replace("joinchat/", "");
|
2015-05-21 23:27:27 +02:00
|
|
|
} else if (path.startsWith("addstickers/")) {
|
|
|
|
sticker = path.replace("addstickers/", "");
|
2016-04-25 21:26:41 +02:00
|
|
|
} else if (path.startsWith("msg/") || path.startsWith("share/")) {
|
2015-10-29 18:10:07 +01:00
|
|
|
message = data.getQueryParameter("url");
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
|
|
|
if (data.getQueryParameter("text") != null) {
|
|
|
|
if (message.length() > 0) {
|
|
|
|
hasUrl = true;
|
|
|
|
message += "\n";
|
|
|
|
}
|
|
|
|
message += data.getQueryParameter("text");
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (message.length() > 4096 * 4) {
|
|
|
|
message = message.substring(0, 4096 * 4);
|
|
|
|
}
|
|
|
|
while (message.endsWith("\n")) {
|
|
|
|
message = message.substring(0, message.length() - 1);
|
|
|
|
}
|
|
|
|
} else if (path.startsWith("confirmphone")) {
|
|
|
|
phone = data.getQueryParameter("phone");
|
|
|
|
phoneHash = data.getQueryParameter("hash");
|
2016-03-06 02:49:31 +01:00
|
|
|
} else if (path.length() >= 1) {
|
|
|
|
List<String> segments = data.getPathSegments();
|
|
|
|
if (segments.size() > 0) {
|
|
|
|
username = segments.get(0);
|
|
|
|
if (segments.size() > 1) {
|
|
|
|
messageId = Utilities.parseInt(segments.get(1));
|
|
|
|
if (messageId == 0) {
|
|
|
|
messageId = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
botUser = data.getQueryParameter("start");
|
|
|
|
botChat = data.getQueryParameter("startgroup");
|
2016-10-11 13:57:01 +02:00
|
|
|
game = data.getQueryParameter("game");
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
2014-04-01 03:00:35 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else if (scheme.equals("tg")) {
|
2015-05-03 13:48:36 +02:00
|
|
|
String url = data.toString();
|
2015-02-26 02:32:51 +01:00
|
|
|
if (url.startsWith("tg:resolve") || url.startsWith("tg://resolve")) {
|
|
|
|
url = url.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org");
|
|
|
|
data = Uri.parse(url);
|
|
|
|
username = data.getQueryParameter("domain");
|
2015-06-29 19:12:11 +02:00
|
|
|
botUser = data.getQueryParameter("start");
|
|
|
|
botChat = data.getQueryParameter("startgroup");
|
2016-10-11 13:57:01 +02:00
|
|
|
game = data.getQueryParameter("game");
|
2016-06-24 12:27:15 +02:00
|
|
|
messageId = Utilities.parseInt(data.getQueryParameter("post"));
|
|
|
|
if (messageId == 0) {
|
|
|
|
messageId = null;
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
} else if (url.startsWith("tg:join") || url.startsWith("tg://join")) {
|
|
|
|
url = url.replace("tg:join", "tg://telegram.org").replace("tg://join", "tg://telegram.org");
|
|
|
|
data = Uri.parse(url);
|
|
|
|
group = data.getQueryParameter("invite");
|
2015-05-21 23:27:27 +02:00
|
|
|
} else if (url.startsWith("tg:addstickers") || url.startsWith("tg://addstickers")) {
|
|
|
|
url = url.replace("tg:addstickers", "tg://telegram.org").replace("tg://addstickers", "tg://telegram.org");
|
|
|
|
data = Uri.parse(url);
|
|
|
|
sticker = data.getQueryParameter("set");
|
2016-04-25 21:26:41 +02:00
|
|
|
} else if (url.startsWith("tg:msg") || url.startsWith("tg://msg") || url.startsWith("tg://share") || url.startsWith("tg:share")) {
|
|
|
|
url = url.replace("tg:msg", "tg://telegram.org").replace("tg://msg", "tg://telegram.org").replace("tg://share", "tg://telegram.org").replace("tg:share", "tg://telegram.org");
|
2015-08-13 11:23:31 +02:00
|
|
|
data = Uri.parse(url);
|
2015-10-29 18:10:07 +01:00
|
|
|
message = data.getQueryParameter("url");
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
|
|
|
if (data.getQueryParameter("text") != null) {
|
|
|
|
if (message.length() > 0) {
|
|
|
|
hasUrl = true;
|
|
|
|
message += "\n";
|
|
|
|
}
|
|
|
|
message += data.getQueryParameter("text");
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (message.length() > 4096 * 4) {
|
|
|
|
message = message.substring(0, 4096 * 4);
|
|
|
|
}
|
|
|
|
while (message.endsWith("\n")) {
|
|
|
|
message = message.substring(0, message.length() - 1);
|
|
|
|
}
|
|
|
|
} else if (url.startsWith("tg:confirmphone") || url.startsWith("tg://confirmphone")) {
|
|
|
|
phone = data.getQueryParameter("phone");
|
|
|
|
phoneHash = data.getQueryParameter("hash");
|
2014-12-01 18:56:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (phone != null || phoneHash != null) {
|
|
|
|
final Bundle args = new Bundle();
|
|
|
|
args.putString("phone", phone);
|
|
|
|
args.putString("hash", phoneHash);
|
|
|
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
presentFragment(new CancelAccountDeletionActivity(args));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (username != null || group != null || sticker != null || message != null || game != null) {
|
|
|
|
runLinkRequest(username, group, sticker, botUser, botChat, message, hasUrl, messageId, game, 0);
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null);
|
|
|
|
if (cursor != null) {
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
int userId = cursor.getInt(cursor.getColumnIndex("DATA4"));
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
push_user_id = userId;
|
|
|
|
}
|
|
|
|
cursor.close();
|
2014-12-01 18:56:31 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
2014-12-01 18:56:31 +01:00
|
|
|
}
|
2014-05-17 01:05:49 +02:00
|
|
|
}
|
2014-03-04 20:29:32 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else if (intent.getAction().equals("org.telegram.messenger.OPEN_ACCOUNT")) {
|
|
|
|
open_settings = 1;
|
|
|
|
} else if (intent.getAction().startsWith("com.tmessages.openchat")) {
|
|
|
|
int chatId = intent.getIntExtra("chatId", 0);
|
|
|
|
int userId = intent.getIntExtra("userId", 0);
|
|
|
|
int encId = intent.getIntExtra("encId", 0);
|
|
|
|
if (chatId != 0) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
push_chat_id = chatId;
|
|
|
|
} else if (userId != 0) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
push_user_id = userId;
|
|
|
|
} else if (encId != 0) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
push_enc_id = encId;
|
|
|
|
} else {
|
|
|
|
showDialogsList = true;
|
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
} else if (intent.getAction().equals("com.tmessages.openplayer")) {
|
|
|
|
showPlayer = true;
|
2014-12-01 18:56:31 +01:00
|
|
|
}
|
2014-03-04 20:29:32 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
if (push_user_id != 0) {
|
2015-05-21 23:27:27 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", push_user_id);
|
2016-03-16 13:26:32 +01:00
|
|
|
if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
|
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
|
|
|
if (actionBarLayout.presentFragment(fragment, false, true, true)) {
|
|
|
|
pushOpened = true;
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
} else if (push_chat_id != 0) {
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
2015-02-26 02:32:51 +01:00
|
|
|
args.putInt("chat_id", push_chat_id);
|
2016-03-16 13:26:32 +01:00
|
|
|
if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
|
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
|
|
|
if (actionBarLayout.presentFragment(fragment, false, true, true)) {
|
|
|
|
pushOpened = true;
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else if (push_enc_id != 0) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("enc_id", push_enc_id);
|
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
|
|
|
if (actionBarLayout.presentFragment(fragment, false, true, true)) {
|
|
|
|
pushOpened = true;
|
|
|
|
}
|
|
|
|
} else if (showDialogsList) {
|
|
|
|
if (!AndroidUtilities.isTablet()) {
|
|
|
|
actionBarLayout.removeAllFragments();
|
|
|
|
} else {
|
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
layersActionBarLayout.closeLastFragment(false);
|
2015-02-01 19:51:02 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
pushOpened = false;
|
|
|
|
isNew = false;
|
2015-07-22 20:56:37 +02:00
|
|
|
} else if (showPlayer) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size(); a++) {
|
|
|
|
BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(a);
|
|
|
|
if (fragment instanceof AudioPlayerActivity) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(fragment);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
|
|
|
} else {
|
|
|
|
for (int a = 0; a < actionBarLayout.fragmentsStack.size(); a++) {
|
|
|
|
BaseFragment fragment = actionBarLayout.fragmentsStack.get(a);
|
|
|
|
if (fragment instanceof AudioPlayerActivity) {
|
|
|
|
actionBarLayout.removeFragmentFromStack(fragment);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
|
|
|
}
|
|
|
|
actionBarLayout.presentFragment(new AudioPlayerActivity(), false, true, true);
|
|
|
|
pushOpened = true;
|
2015-02-26 02:32:51 +01:00
|
|
|
} else if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null || documentsUrisArray != null) {
|
|
|
|
if (!AndroidUtilities.isTablet()) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
if (dialogId == 0) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
2015-11-26 22:04:02 +01:00
|
|
|
if (contactsToSend != null) {
|
|
|
|
args.putString("selectAlertString", LocaleController.getString("SendContactTo", R.string.SendMessagesTo));
|
|
|
|
args.putString("selectAlertStringGroup", LocaleController.getString("SendContactToGroup", R.string.SendContactToGroup));
|
|
|
|
} else {
|
|
|
|
args.putString("selectAlertString", LocaleController.getString("SendMessagesTo", R.string.SendMessagesTo));
|
|
|
|
args.putString("selectAlertStringGroup", LocaleController.getString("SendMessagesToGroup", R.string.SendMessagesToGroup));
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
DialogsActivity fragment = new DialogsActivity(args);
|
|
|
|
fragment.setDelegate(this);
|
|
|
|
boolean removeLast;
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
removeLast = layersActionBarLayout.fragmentsStack.size() > 0 && layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
|
|
|
|
} else {
|
|
|
|
removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
|
|
|
|
}
|
|
|
|
actionBarLayout.presentFragment(fragment, removeLast, true, true);
|
|
|
|
pushOpened = true;
|
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
|
|
|
PhotoViewer.getInstance().closePhoto(false, true);
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
|
|
|
} else {
|
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
|
|
|
}
|
2015-03-26 18:34:47 +01:00
|
|
|
} else {
|
2015-10-29 18:10:07 +01:00
|
|
|
didSelectDialog(null, dialogId, false);
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
} else if (open_settings != 0) {
|
|
|
|
actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
2015-03-26 18:34:47 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
|
|
|
} else {
|
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
pushOpened = true;
|
2014-11-19 02:23:46 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
|
|
|
|
if (!pushOpened && !isNew) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!UserConfig.isClientActivated()) {
|
2015-02-26 02:32:51 +01:00
|
|
|
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
layersActionBarLayout.addFragmentToStack(new LoginActivity());
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
2015-07-22 20:56:37 +02:00
|
|
|
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
2015-04-09 20:00:14 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2014-09-28 15:37:26 +02:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
} else {
|
|
|
|
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!UserConfig.isClientActivated()) {
|
2015-02-26 02:32:51 +01:00
|
|
|
actionBarLayout.addFragmentToStack(new LoginActivity());
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
2015-01-02 23:15:07 +01:00
|
|
|
} else {
|
2015-07-22 20:56:37 +02:00
|
|
|
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
2015-04-09 20:00:14 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2015-01-02 23:15:07 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-28 15:37:26 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
layersActionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
2014-09-14 01:40:36 +02:00
|
|
|
}
|
|
|
|
}
|
2014-03-04 20:29:32 +01:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
intent.setAction(null);
|
|
|
|
return pushOpened;
|
|
|
|
}
|
|
|
|
return false;
|
2014-03-04 20:29:32 +01:00
|
|
|
}
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
private void runLinkRequest(final String username, final String group, final String sticker, final String botUser, final String botChat, final String message, final boolean hasUrl, final Integer messageId, final String game, final int state) {
|
2015-05-03 13:48:36 +02:00
|
|
|
final ProgressDialog progressDialog = new ProgressDialog(this);
|
|
|
|
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
|
|
|
progressDialog.setCanceledOnTouchOutside(false);
|
|
|
|
progressDialog.setCancelable(false);
|
2015-09-24 22:52:02 +02:00
|
|
|
int requestId = 0;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
|
|
|
if (username != null) {
|
|
|
|
TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
|
|
|
|
req.username = username;
|
2015-09-24 22:52:02 +02:00
|
|
|
requestId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
|
2015-05-03 13:48:36 +02:00
|
|
|
@Override
|
|
|
|
public void run(final TLObject response, final TLRPC.TL_error error) {
|
|
|
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (!LaunchActivity.this.isFinishing()) {
|
|
|
|
try {
|
|
|
|
progressDialog.dismiss();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
final TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
|
|
|
|
if (error == null && actionBarLayout != null && (game == null || game != null && !res.users.isEmpty())) {
|
2015-09-24 22:52:02 +02:00
|
|
|
MessagesController.getInstance().putUsers(res.users, false);
|
|
|
|
MessagesController.getInstance().putChats(res.chats, false);
|
|
|
|
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, false, true);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (game != null) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
|
|
|
args.putBoolean("cantSendToChannels", true);
|
|
|
|
args.putInt("dialogsType", 1);
|
|
|
|
args.putString("selectAlertString", LocaleController.getString("SendGameTo", R.string.SendGameTo));
|
|
|
|
args.putString("selectAlertStringGroup", LocaleController.getString("SendGameToGroup", R.string.SendGameToGroup));
|
|
|
|
DialogsActivity fragment = new DialogsActivity(args);
|
|
|
|
fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
|
|
|
|
@Override
|
|
|
|
public void didSelectDialog(DialogsActivity fragment, long dialog_id, boolean param) {
|
|
|
|
TLRPC.TL_inputMediaGame inputMediaGame = new TLRPC.TL_inputMediaGame();
|
|
|
|
inputMediaGame.id = new TLRPC.TL_inputGameShortName();
|
|
|
|
inputMediaGame.id.short_name = game;
|
|
|
|
inputMediaGame.id.bot_id = MessagesController.getInputUser(res.users.get(0));
|
|
|
|
SendMessagesHelper.getInstance().sendGame(MessagesController.getInputPeer((int) dialog_id), inputMediaGame, 0, 0);
|
2015-09-24 22:52:02 +02:00
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("scrollToTopOnResume", true);
|
|
|
|
int lower_part = (int) dialog_id;
|
|
|
|
int high_id = (int) (dialog_id >> 32);
|
|
|
|
if (lower_part != 0) {
|
|
|
|
if (high_id == 1) {
|
|
|
|
args.putInt("chat_id", lower_part);
|
|
|
|
} else {
|
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
args.putInt("chat_id", -lower_part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
args.putInt("enc_id", high_id);
|
|
|
|
}
|
|
|
|
if (MessagesController.checkCanOpenChat(args, fragment)) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
actionBarLayout.presentFragment(new ChatActivity(args), true, false, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
boolean removeLast;
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
removeLast = layersActionBarLayout.fragmentsStack.size() > 0 && layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
|
|
|
|
} else {
|
|
|
|
removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
|
|
|
|
}
|
|
|
|
actionBarLayout.presentFragment(fragment, removeLast, true, true);
|
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
|
|
|
PhotoViewer.getInstance().closePhoto(false, true);
|
|
|
|
}
|
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
rightActionBarLayout.showLastFragment();
|
|
|
|
} else {
|
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
|
|
|
}
|
|
|
|
} else if (botChat != null) {
|
2015-09-24 22:52:02 +02:00
|
|
|
final TLRPC.User user = !res.users.isEmpty() ? res.users.get(0) : null;
|
2015-11-26 22:04:02 +01:00
|
|
|
if (user == null || user.bot && user.bot_nochats) {
|
2015-06-29 19:12:11 +02:00
|
|
|
try {
|
|
|
|
Toast.makeText(LaunchActivity.this, LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups), Toast.LENGTH_SHORT).show();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
|
|
|
args.putInt("dialogsType", 2);
|
|
|
|
args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getUserName(user), "%1$s"));
|
2015-07-22 20:56:37 +02:00
|
|
|
DialogsActivity fragment = new DialogsActivity(args);
|
2016-04-22 15:49:00 +02:00
|
|
|
fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
|
2015-06-29 19:12:11 +02:00
|
|
|
@Override
|
2015-07-22 20:56:37 +02:00
|
|
|
public void didSelectDialog(DialogsActivity fragment, long did, boolean param) {
|
2015-06-29 19:12:11 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("scrollToTopOnResume", true);
|
|
|
|
args.putInt("chat_id", -(int) did);
|
2016-03-16 13:26:32 +01:00
|
|
|
if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
MessagesController.getInstance().addUserToChat(-(int) did, user, null, 0, botChat, null);
|
|
|
|
actionBarLayout.presentFragment(new ChatActivity(args), true, false, true);
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
presentFragment(fragment);
|
|
|
|
} else {
|
2016-04-22 15:49:00 +02:00
|
|
|
long dialog_id;
|
|
|
|
boolean isBot = false;
|
2015-06-29 19:12:11 +02:00
|
|
|
Bundle args = new Bundle();
|
2015-09-24 22:52:02 +02:00
|
|
|
if (!res.chats.isEmpty()) {
|
|
|
|
args.putInt("chat_id", res.chats.get(0).id);
|
2016-04-22 15:49:00 +02:00
|
|
|
dialog_id = -res.chats.get(0).id;
|
2015-09-24 22:52:02 +02:00
|
|
|
} else {
|
|
|
|
args.putInt("user_id", res.users.get(0).id);
|
2016-04-22 15:49:00 +02:00
|
|
|
dialog_id = res.users.get(0).id;
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
2015-11-26 22:04:02 +01:00
|
|
|
if (botUser != null && res.users.size() > 0 && res.users.get(0).bot) {
|
2015-06-29 19:12:11 +02:00
|
|
|
args.putString("botUser", botUser);
|
2016-04-22 15:49:00 +02:00
|
|
|
isBot = true;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
if (messageId != null) {
|
|
|
|
args.putInt("message_id", messageId);
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
BaseFragment lastFragment = !mainFragmentsStack.isEmpty() ? mainFragmentsStack.get(mainFragmentsStack.size() - 1) : null;
|
|
|
|
if (lastFragment == null || MessagesController.checkCanOpenChat(args, lastFragment)) {
|
|
|
|
if (isBot && lastFragment != null && lastFragment instanceof ChatActivity && ((ChatActivity) lastFragment).getDialogId() == dialog_id) {
|
|
|
|
((ChatActivity) lastFragment).setBotUser(botUser);
|
|
|
|
} else {
|
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
actionBarLayout.presentFragment(fragment, false, true, true);
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
Toast.makeText(LaunchActivity.this, LocaleController.getString("NoUsernameFound", R.string.NoUsernameFound), Toast.LENGTH_SHORT).show();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (group != null) {
|
|
|
|
if (state == 0) {
|
|
|
|
final TLRPC.TL_messages_checkChatInvite req = new TLRPC.TL_messages_checkChatInvite();
|
|
|
|
req.hash = group;
|
2015-09-24 22:52:02 +02:00
|
|
|
requestId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
|
2015-05-03 13:48:36 +02:00
|
|
|
@Override
|
|
|
|
public void run(final TLObject response, final TLRPC.TL_error error) {
|
|
|
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (!LaunchActivity.this.isFinishing()) {
|
|
|
|
try {
|
|
|
|
progressDialog.dismiss();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
if (error == null && actionBarLayout != null) {
|
|
|
|
TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response;
|
2015-09-24 22:52:02 +02:00
|
|
|
if (invite.chat != null && !ChatObject.isLeftFromChat(invite.chat)) {
|
2015-05-03 13:48:36 +02:00
|
|
|
MessagesController.getInstance().putChat(invite.chat, false);
|
|
|
|
ArrayList<TLRPC.Chat> chats = new ArrayList<>();
|
|
|
|
chats.add(invite.chat);
|
|
|
|
MessagesStorage.getInstance().putUsersAndChats(null, chats, false, true);
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("chat_id", invite.chat.id);
|
2016-03-16 13:26:32 +01:00
|
|
|
if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
|
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
actionBarLayout.presentFragment(fragment, false, true, true);
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
} else {
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((invite.chat == null && (!invite.channel || invite.megagroup) || invite.chat != null && (!ChatObject.isChannel(invite.chat) || invite.chat.megagroup)) && !mainFragmentsStack.isEmpty()) {
|
|
|
|
BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
|
|
|
|
fragment.showDialog(new JoinGroupAlert(LaunchActivity.this, invite, group, fragment));
|
2015-09-24 22:52:02 +02:00
|
|
|
} else {
|
2016-10-11 13:57:01 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
if (!invite.megagroup && invite.channel || ChatObject.isChannel(invite.chat) && !invite.chat.megagroup) {
|
|
|
|
builder.setMessage(LocaleController.formatString("ChannelJoinTo", R.string.ChannelJoinTo, invite.chat != null ? invite.chat.title : invite.title));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.formatString("JoinToGroup", R.string.JoinToGroup, invite.chat != null ? invite.chat.title : invite.title));
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
runLinkRequest(username, group, sticker, botUser, botChat, message, hasUrl, messageId, game, 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showAlertDialog(builder);
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
2015-12-09 19:27:52 +01:00
|
|
|
if (error.text.startsWith("FLOOD_WAIT")) {
|
|
|
|
builder.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showAlertDialog(builder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-12-09 19:27:52 +01:00
|
|
|
}, ConnectionsManager.RequestFlagFailOnServerErrors);
|
2015-05-03 13:48:36 +02:00
|
|
|
} else if (state == 1) {
|
|
|
|
TLRPC.TL_messages_importChatInvite req = new TLRPC.TL_messages_importChatInvite();
|
|
|
|
req.hash = group;
|
2015-09-24 22:52:02 +02:00
|
|
|
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
|
2015-05-03 13:48:36 +02:00
|
|
|
@Override
|
|
|
|
public void run(final TLObject response, final TLRPC.TL_error error) {
|
|
|
|
if (error == null) {
|
|
|
|
TLRPC.Updates updates = (TLRPC.Updates) response;
|
|
|
|
MessagesController.getInstance().processUpdates(updates, false);
|
|
|
|
}
|
|
|
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (!LaunchActivity.this.isFinishing()) {
|
|
|
|
try {
|
|
|
|
progressDialog.dismiss();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
if (error == null) {
|
|
|
|
if (actionBarLayout != null) {
|
|
|
|
TLRPC.Updates updates = (TLRPC.Updates) response;
|
|
|
|
if (!updates.chats.isEmpty()) {
|
2015-12-09 19:27:52 +01:00
|
|
|
TLRPC.Chat chat = updates.chats.get(0);
|
|
|
|
chat.left = false;
|
|
|
|
chat.kicked = false;
|
2015-05-03 13:48:36 +02:00
|
|
|
MessagesController.getInstance().putUsers(updates.users, false);
|
|
|
|
MessagesController.getInstance().putChats(updates.chats, false);
|
|
|
|
Bundle args = new Bundle();
|
2015-12-09 19:27:52 +01:00
|
|
|
args.putInt("chat_id", chat.id);
|
2016-03-16 13:26:32 +01:00
|
|
|
if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
|
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
actionBarLayout.presentFragment(fragment, false, true, true);
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
2015-12-09 19:27:52 +01:00
|
|
|
if (error.text.startsWith("FLOOD_WAIT")) {
|
|
|
|
builder.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
|
|
|
|
} else if (error.text.equals("USERS_TOO_MUCH")) {
|
2015-05-03 13:48:36 +02:00
|
|
|
builder.setMessage(LocaleController.getString("JoinToGroupErrorFull", R.string.JoinToGroupErrorFull));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
|
|
|
|
}
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showAlertDialog(builder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-12-09 19:27:52 +01:00
|
|
|
}, ConnectionsManager.RequestFlagFailOnServerErrors);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
} else if (sticker != null) {
|
|
|
|
if (!mainFragmentsStack.isEmpty()) {
|
|
|
|
TLRPC.TL_inputStickerSetShortName stickerset = new TLRPC.TL_inputStickerSetShortName();
|
|
|
|
stickerset.short_name = sticker;
|
2016-10-11 13:57:01 +02:00
|
|
|
BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
|
|
|
|
fragment.showDialog(new StickersAlert(LaunchActivity.this, fragment, stickerset, null, null));
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
|
|
|
return;
|
2015-08-13 11:23:31 +02:00
|
|
|
} else if (message != null) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
|
|
|
DialogsActivity fragment = new DialogsActivity(args);
|
2016-04-22 15:49:00 +02:00
|
|
|
fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
|
2015-08-13 11:23:31 +02:00
|
|
|
@Override
|
|
|
|
public void didSelectDialog(DialogsActivity fragment, long did, boolean param) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("scrollToTopOnResume", true);
|
2015-10-29 18:10:07 +01:00
|
|
|
args.putBoolean("hasUrl", hasUrl);
|
2015-08-13 11:23:31 +02:00
|
|
|
int lower_part = (int) did;
|
|
|
|
int high_id = (int) (did >> 32);
|
|
|
|
if (lower_part != 0) {
|
|
|
|
if (high_id == 1) {
|
|
|
|
args.putInt("chat_id", lower_part);
|
|
|
|
} else {
|
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
args.putInt("chat_id", -lower_part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
args.putInt("enc_id", high_id);
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
if (MessagesController.checkCanOpenChat(args, fragment)) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
2016-06-24 12:27:15 +02:00
|
|
|
DraftQuery.saveDraft(did, message, null, null, true);
|
2016-03-16 13:26:32 +01:00
|
|
|
actionBarLayout.presentFragment(new ChatActivity(args), true, false, true);
|
|
|
|
}
|
2015-08-13 11:23:31 +02:00
|
|
|
}
|
|
|
|
});
|
2015-10-29 18:10:07 +01:00
|
|
|
presentFragment(fragment, false, true);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
2015-08-13 11:23:31 +02:00
|
|
|
if (requestId != 0) {
|
2015-09-24 22:52:02 +02:00
|
|
|
final int reqId = requestId;
|
2015-08-13 11:23:31 +02:00
|
|
|
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2015-09-24 22:52:02 +02:00
|
|
|
ConnectionsManager.getInstance().cancelRequest(reqId, true);
|
2015-08-13 11:23:31 +02:00
|
|
|
try {
|
|
|
|
dialog.dismiss();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-08-13 11:23:31 +02:00
|
|
|
});
|
|
|
|
progressDialog.show();
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public AlertDialog showAlertDialog(AlertDialog.Builder builder) {
|
|
|
|
try {
|
|
|
|
if (visibleDialog != null) {
|
|
|
|
visibleDialog.dismiss();
|
|
|
|
visibleDialog = null;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
visibleDialog = builder.show();
|
|
|
|
visibleDialog.setCanceledOnTouchOutside(true);
|
|
|
|
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
@Override
|
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
|
visibleDialog = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return visibleDialog;
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-03-04 20:29:32 +01:00
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
super.onNewIntent(intent);
|
2015-02-26 02:32:51 +01:00
|
|
|
handleIntent(intent, true, false, false);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-29 18:10:07 +01:00
|
|
|
public void didSelectDialog(DialogsActivity dialogsFragment, long dialog_id, boolean param) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (dialog_id != 0) {
|
|
|
|
int lower_part = (int)dialog_id;
|
2014-07-27 12:53:00 +02:00
|
|
|
int high_id = (int)(dialog_id >> 32);
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("scrollToTopOnResume", true);
|
2014-09-28 15:37:26 +02:00
|
|
|
if (!AndroidUtilities.isTablet()) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
if (lower_part != 0) {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (high_id == 1) {
|
|
|
|
args.putInt("chat_id", lower_part);
|
2014-07-27 00:28:33 +02:00
|
|
|
} else {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
args.putInt("chat_id", -lower_part);
|
|
|
|
}
|
2014-07-27 00:28:33 +02:00
|
|
|
}
|
2014-07-27 12:53:00 +02:00
|
|
|
} else {
|
|
|
|
args.putInt("enc_id", high_id);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
if (!MessagesController.checkCanOpenChat(args, dialogsFragment)) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
ChatActivity fragment = new ChatActivity(args);
|
2014-09-30 00:48:11 +02:00
|
|
|
|
2014-04-01 03:00:35 +02:00
|
|
|
if (videoPath != null) {
|
2014-09-30 00:48:11 +02:00
|
|
|
if(android.os.Build.VERSION.SDK_INT >= 16) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
actionBarLayout.presentFragment(fragment, false, true, true);
|
2015-10-29 18:10:07 +01:00
|
|
|
} else {
|
2014-10-20 13:30:05 +02:00
|
|
|
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
if (!fragment.openVideoEditor(videoPath, dialogsFragment != null, false) && dialogsFragment != null) {
|
2014-10-15 20:43:52 +02:00
|
|
|
if (!AndroidUtilities.isTablet()) {
|
2015-10-29 18:10:07 +01:00
|
|
|
dialogsFragment.finishFragment(true);
|
2014-10-15 20:43:52 +02:00
|
|
|
}
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-29 18:10:07 +01:00
|
|
|
actionBarLayout.presentFragment(fragment, dialogsFragment != null, dialogsFragment == null, true);
|
2016-10-11 13:57:01 +02:00
|
|
|
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, null, null);
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-29 18:10:07 +01:00
|
|
|
actionBarLayout.presentFragment(fragment, dialogsFragment != null, dialogsFragment == null, true);
|
2015-06-29 19:12:11 +02:00
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
if (photoPathsArray != null) {
|
|
|
|
ArrayList<String> captions = null;
|
2016-10-11 13:57:01 +02:00
|
|
|
if (sendingText != null && sendingText.length() <= 200 && photoPathsArray.size() == 1) {
|
2016-05-25 23:49:47 +02:00
|
|
|
captions = new ArrayList<>();
|
|
|
|
captions.add(sendingText);
|
|
|
|
sendingText = null;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id, null, captions, null);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2014-09-30 00:48:11 +02:00
|
|
|
if (sendingText != null) {
|
2016-06-24 12:27:15 +02:00
|
|
|
SendMessagesHelper.prepareSendingText(sendingText, dialog_id);
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
|
2014-11-21 01:14:44 +01:00
|
|
|
if (documentsPathsArray != null || documentsUrisArray != null) {
|
2016-06-24 12:27:15 +02:00
|
|
|
SendMessagesHelper.prepareSendingDocuments(documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, documentsMimeType, dialog_id, null);
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
|
|
|
if (contactsToSend != null && !contactsToSend.isEmpty()) {
|
|
|
|
for (TLRPC.User user : contactsToSend) {
|
2016-06-24 12:27:15 +02:00
|
|
|
SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null, null, null);
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
2014-03-22 23:31:55 +01:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-06-20 02:18:13 +02:00
|
|
|
|
|
|
|
photoPathsArray = null;
|
2013-10-25 17:19:00 +02:00
|
|
|
videoPath = null;
|
|
|
|
sendingText = null;
|
2014-06-20 02:18:13 +02:00
|
|
|
documentsPathsArray = null;
|
|
|
|
documentsOriginalPathsArray = null;
|
2014-03-22 23:31:55 +01:00
|
|
|
contactsToSend = null;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
private void onFinish() {
|
|
|
|
if (finished) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
finished = true;
|
2015-02-26 02:32:51 +01:00
|
|
|
if (lockRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(lockRunnable);
|
|
|
|
lockRunnable = null;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
|
2014-11-17 03:44:57 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged);
|
2014-09-24 04:17:27 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState);
|
2015-12-09 19:27:52 +01:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.needShowAlert);
|
2016-04-22 15:49:00 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
|
2016-10-11 13:57:01 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void presentFragment(BaseFragment fragment) {
|
|
|
|
actionBarLayout.presentFragment(fragment);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation) {
|
2014-09-28 15:37:26 +02:00
|
|
|
return actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, true);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
|
2014-03-26 21:16:28 +01:00
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
2015-02-26 02:32:51 +01:00
|
|
|
if (UserConfig.passcodeHash.length() != 0 && UserConfig.lastPauseTime != 0) {
|
|
|
|
UserConfig.lastPauseTime = 0;
|
|
|
|
UserConfig.saveConfig(false);
|
|
|
|
}
|
2014-03-26 21:16:28 +01:00
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
2014-09-24 04:17:27 +02:00
|
|
|
if (actionBarLayout.fragmentsStack.size() != 0) {
|
|
|
|
BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
2014-03-26 21:16:28 +01:00
|
|
|
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (rightActionBarLayout.fragmentsStack.size() != 0) {
|
|
|
|
BaseFragment fragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
|
|
|
}
|
|
|
|
if (layersActionBarLayout.fragmentsStack.size() != 0) {
|
|
|
|
BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
|
|
|
}
|
|
|
|
}
|
2014-03-26 21:16:28 +01:00
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (requestCode == 3 || requestCode == 4 || requestCode == 5 || requestCode == 19 || requestCode == 20) {
|
|
|
|
boolean showAlert = true;
|
2016-01-11 18:19:48 +01:00
|
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
2015-10-29 18:10:07 +01:00
|
|
|
if (requestCode == 4) {
|
2016-03-06 02:49:31 +01:00
|
|
|
ImageLoader.getInstance().checkMediaPaths();
|
2016-10-11 13:57:01 +02:00
|
|
|
return;
|
2015-10-29 18:10:07 +01:00
|
|
|
} else if (requestCode == 5) {
|
|
|
|
ContactsController.getInstance().readContacts();
|
2016-10-11 13:57:01 +02:00
|
|
|
return;
|
|
|
|
} else if (requestCode == 3) {
|
|
|
|
return;
|
|
|
|
} else if (requestCode == 19 || requestCode == 20) {
|
|
|
|
showAlert = false;
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (showAlert) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
if (requestCode == 3) {
|
|
|
|
builder.setMessage(LocaleController.getString("PermissionNoAudio", R.string.PermissionNoAudio));
|
|
|
|
} else if (requestCode == 4) {
|
|
|
|
builder.setMessage(LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
|
|
|
|
} else if (requestCode == 5) {
|
|
|
|
builder.setMessage(LocaleController.getString("PermissionContacts", R.string.PermissionContacts));
|
|
|
|
} else if (requestCode == 19 || requestCode == 20) {
|
|
|
|
builder.setMessage(LocaleController.getString("PermissionNoCamera", R.string.PermissionNoCamera));
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() {
|
|
|
|
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
|
|
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
|
|
|
|
startActivity(intent);
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
builder.show();
|
|
|
|
return;
|
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
} else if (requestCode == 2) {
|
|
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.locationPermissionGranted);
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
if (actionBarLayout.fragmentsStack.size() != 0) {
|
|
|
|
BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
|
|
|
}
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (rightActionBarLayout.fragmentsStack.size() != 0) {
|
|
|
|
BaseFragment fragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
|
|
|
}
|
|
|
|
if (layersActionBarLayout.fragmentsStack.size() != 0) {
|
|
|
|
BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
2015-10-29 18:10:07 +01:00
|
|
|
ApplicationLoader.mainInterfacePaused = true;
|
2015-02-26 02:32:51 +01:00
|
|
|
onPasscodePause();
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.onPause();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
rightActionBarLayout.onPause();
|
|
|
|
layersActionBarLayout.onPause();
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
if (passcodeView != null) {
|
|
|
|
passcodeView.onPause();
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
ConnectionsManager.getInstance().setAppPaused(true, false);
|
2015-05-21 23:27:27 +02:00
|
|
|
AndroidUtilities.unregisterUpdates();
|
2016-05-25 23:49:47 +02:00
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
|
|
|
PhotoViewer.getInstance().onPause();
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
@Override
|
|
|
|
protected void onStart() {
|
|
|
|
super.onStart();
|
|
|
|
Browser.bindCustomTabsService(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop() {
|
|
|
|
super.onStop();
|
|
|
|
Browser.unbindCustomTabsService(this);
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
2014-07-12 00:14:13 +02:00
|
|
|
PhotoViewer.getInstance().destroyPhotoViewer();
|
2014-10-09 17:55:05 +02:00
|
|
|
SecretPhotoViewer.getInstance().destroyPhotoViewer();
|
2015-08-13 11:23:31 +02:00
|
|
|
StickerPreviewViewer.getInstance().destroy();
|
2015-05-03 13:48:36 +02:00
|
|
|
try {
|
|
|
|
if (visibleDialog != null) {
|
|
|
|
visibleDialog.dismiss();
|
|
|
|
visibleDialog = null;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2015-11-26 22:04:02 +01:00
|
|
|
try {
|
|
|
|
if (onGlobalLayoutListener != null) {
|
|
|
|
final View view = getWindow().getDecorView().getRootView();
|
|
|
|
if (Build.VERSION.SDK_INT < 16) {
|
|
|
|
view.getViewTreeObserver().removeGlobalOnLayoutListener(onGlobalLayoutListener);
|
|
|
|
} else {
|
|
|
|
view.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
super.onDestroy();
|
2014-06-04 01:31:48 +02:00
|
|
|
onFinish();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
2015-10-29 18:10:07 +01:00
|
|
|
ApplicationLoader.mainInterfacePaused = false;
|
2015-02-26 02:32:51 +01:00
|
|
|
onPasscodeResume();
|
|
|
|
if (passcodeView.getVisibility() != View.VISIBLE) {
|
|
|
|
actionBarLayout.onResume();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
rightActionBarLayout.onResume();
|
|
|
|
layersActionBarLayout.onResume();
|
|
|
|
}
|
|
|
|
} else {
|
2016-10-11 13:57:01 +02:00
|
|
|
actionBarLayout.dismissDialogs();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
rightActionBarLayout.dismissDialogs();
|
|
|
|
layersActionBarLayout.dismissDialogs();
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
passcodeView.onResume();
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
AndroidUtilities.checkForCrashes(this);
|
|
|
|
AndroidUtilities.checkForUpdates(this);
|
2014-07-03 00:39:05 +02:00
|
|
|
ConnectionsManager.getInstance().setAppPaused(false, false);
|
2014-11-18 06:01:04 +01:00
|
|
|
updateCurrentConnectionState();
|
2015-05-03 13:48:36 +02:00
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
|
|
|
PhotoViewer.getInstance().onResume();
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-11 13:57:01 +02:00
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
AndroidUtilities.checkDisplaySize(this, newConfig);
|
2014-09-24 04:17:27 +02:00
|
|
|
super.onConfigurationChanged(newConfig);
|
2016-10-11 13:57:01 +02:00
|
|
|
checkLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
|
|
|
|
AndroidUtilities.isInMultiwindow = isInMultiWindowMode;
|
|
|
|
checkLayout();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public void didReceivedNotification(int id, Object... args) {
|
2014-08-22 16:24:33 +02:00
|
|
|
if (id == NotificationCenter.appDidLogout) {
|
2014-11-21 11:59:05 +01:00
|
|
|
if (drawerLayoutAdapter != null) {
|
|
|
|
drawerLayoutAdapter.notifyDataSetChanged();
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
for (BaseFragment fragment : actionBarLayout.fragmentsStack) {
|
2013-10-25 17:19:00 +02:00
|
|
|
fragment.onFragmentDestroy();
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.fragmentsStack.clear();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
for (BaseFragment fragment : layersActionBarLayout.fragmentsStack) {
|
|
|
|
fragment.onFragmentDestroy();
|
|
|
|
}
|
|
|
|
layersActionBarLayout.fragmentsStack.clear();
|
|
|
|
for (BaseFragment fragment : rightActionBarLayout.fragmentsStack) {
|
|
|
|
fragment.onFragmentDestroy();
|
|
|
|
}
|
|
|
|
rightActionBarLayout.fragmentsStack.clear();
|
|
|
|
}
|
2014-03-04 20:29:32 +01:00
|
|
|
Intent intent2 = new Intent(this, IntroActivity.class);
|
2013-10-25 17:19:00 +02:00
|
|
|
startActivity(intent2);
|
2014-06-04 01:31:48 +02:00
|
|
|
onFinish();
|
2013-10-25 17:19:00 +02:00
|
|
|
finish();
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.closeOtherAppActivities) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (args[0] != this) {
|
2014-06-04 01:31:48 +02:00
|
|
|
onFinish();
|
2015-02-26 02:32:51 +01:00
|
|
|
finish();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.didUpdatedConnectionState) {
|
2015-09-24 22:52:02 +02:00
|
|
|
int state = ConnectionsManager.getInstance().getConnectionState();
|
2013-10-25 17:19:00 +02:00
|
|
|
if (currentConnectionState != state) {
|
2015-09-24 22:52:02 +02:00
|
|
|
FileLog.d("tmessages", "switch to state " + state);
|
2013-10-25 17:19:00 +02:00
|
|
|
currentConnectionState = state;
|
2014-11-18 06:01:04 +01:00
|
|
|
updateCurrentConnectionState();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
} else if (id == NotificationCenter.mainUserInfoChanged) {
|
|
|
|
drawerLayoutAdapter.notifyDataSetChanged();
|
2015-12-09 19:27:52 +01:00
|
|
|
} else if (id == NotificationCenter.needShowAlert) {
|
2015-09-24 22:52:02 +02:00
|
|
|
final Integer reason = (Integer) args[0];
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
2015-12-09 19:27:52 +01:00
|
|
|
if (reason != 2) {
|
|
|
|
builder.setNegativeButton(LocaleController.getString("MoreInfo", R.string.MoreInfo), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
2016-04-22 15:49:00 +02:00
|
|
|
if (!mainFragmentsStack.isEmpty()) {
|
|
|
|
MessagesController.openByUserName("spambot", mainFragmentsStack.get(mainFragmentsStack.size() - 1), 1);
|
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
2015-12-09 19:27:52 +01:00
|
|
|
});
|
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
if (reason == 0) {
|
|
|
|
builder.setMessage(LocaleController.getString("NobodyLikesSpam1", R.string.NobodyLikesSpam1));
|
|
|
|
} else if (reason == 1) {
|
|
|
|
builder.setMessage(LocaleController.getString("NobodyLikesSpam2", R.string.NobodyLikesSpam2));
|
2015-12-09 19:27:52 +01:00
|
|
|
} else if (reason == 2) {
|
|
|
|
builder.setMessage((String) args[1]);
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
|
|
|
if (!mainFragmentsStack.isEmpty()) {
|
|
|
|
mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(builder.create());
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
} else if (id == NotificationCenter.wasUnableToFindCurrentLocation) {
|
|
|
|
final HashMap<String, MessageObject> waitingForLocation = (HashMap<String, MessageObject>) args[0];
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
builder.setNegativeButton(LocaleController.getString("ShareYouLocationUnableManually", R.string.ShareYouLocationUnableManually), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
if (mainFragmentsStack.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BaseFragment lastFragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
|
|
|
|
if (!AndroidUtilities.isGoogleMapsInstalled(lastFragment)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
LocationActivity fragment = new LocationActivity();
|
|
|
|
fragment.setDelegate(new LocationActivity.LocationActivityDelegate() {
|
|
|
|
@Override
|
|
|
|
public void didSelectLocation(TLRPC.MessageMedia location) {
|
|
|
|
for (HashMap.Entry<String, MessageObject> entry : waitingForLocation.entrySet()) {
|
|
|
|
MessageObject messageObject = entry.getValue();
|
2016-06-24 12:27:15 +02:00
|
|
|
SendMessagesHelper.getInstance().sendMessage(location, messageObject.getDialogId(), messageObject, null, null);
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
presentFragment(fragment);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setMessage(LocaleController.getString("ShareYouLocationUnable", R.string.ShareYouLocationUnable));
|
|
|
|
if (!mainFragmentsStack.isEmpty()) {
|
|
|
|
mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(builder.create());
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
} else if (id == NotificationCenter.didSetNewWallpapper) {
|
|
|
|
if (listView != null) {
|
|
|
|
View child = listView.getChildAt(0);
|
|
|
|
if (child != null) {
|
|
|
|
child.invalidate();
|
|
|
|
}
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onPasscodePause() {
|
|
|
|
if (lockRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(lockRunnable);
|
|
|
|
lockRunnable = null;
|
|
|
|
}
|
|
|
|
if (UserConfig.passcodeHash.length() != 0) {
|
|
|
|
UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime();
|
|
|
|
lockRunnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (lockRunnable == this) {
|
|
|
|
if (AndroidUtilities.needShowPasscode(true)) {
|
|
|
|
FileLog.e("tmessages", "lock app");
|
|
|
|
showPasscodeActivity();
|
|
|
|
} else {
|
|
|
|
FileLog.e("tmessages", "didn't pass lock check");
|
|
|
|
}
|
|
|
|
lockRunnable = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (UserConfig.appLocked) {
|
|
|
|
AndroidUtilities.runOnUIThread(lockRunnable, 1000);
|
|
|
|
} else if (UserConfig.autoLockIn != 0) {
|
|
|
|
AndroidUtilities.runOnUIThread(lockRunnable, (long) UserConfig.autoLockIn * 1000 + 1000);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UserConfig.lastPauseTime = 0;
|
|
|
|
}
|
|
|
|
UserConfig.saveConfig(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onPasscodeResume() {
|
|
|
|
if (lockRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(lockRunnable);
|
|
|
|
lockRunnable = null;
|
|
|
|
}
|
|
|
|
if (AndroidUtilities.needShowPasscode(true)) {
|
|
|
|
showPasscodeActivity();
|
|
|
|
}
|
|
|
|
if (UserConfig.lastPauseTime != 0) {
|
|
|
|
UserConfig.lastPauseTime = 0;
|
|
|
|
UserConfig.saveConfig(false);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 06:01:04 +01:00
|
|
|
private void updateCurrentConnectionState() {
|
|
|
|
String text = null;
|
2015-09-24 22:52:02 +02:00
|
|
|
if (currentConnectionState == ConnectionsManager.ConnectionStateWaitingForNetwork) {
|
2014-11-18 06:01:04 +01:00
|
|
|
text = LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork);
|
2015-09-24 22:52:02 +02:00
|
|
|
} else if (currentConnectionState == ConnectionsManager.ConnectionStateConnecting) {
|
2014-11-18 06:01:04 +01:00
|
|
|
text = LocaleController.getString("Connecting", R.string.Connecting);
|
2015-09-24 22:52:02 +02:00
|
|
|
} else if (currentConnectionState == ConnectionsManager.ConnectionStateUpdating) {
|
2014-11-18 06:01:04 +01:00
|
|
|
text = LocaleController.getString("Updating", R.string.Updating);
|
|
|
|
}
|
|
|
|
actionBarLayout.setTitleOverlayText(text);
|
|
|
|
}
|
|
|
|
|
2013-12-20 20:25:49 +01:00
|
|
|
@Override
|
|
|
|
protected void onSaveInstanceState(Bundle outState) {
|
|
|
|
try {
|
|
|
|
super.onSaveInstanceState(outState);
|
2014-09-28 15:37:26 +02:00
|
|
|
BaseFragment lastFragment = null;
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
lastFragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
} else if (!rightActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
lastFragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
} else if (!actionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!actionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastFragment != null) {
|
2014-03-26 21:16:28 +01:00
|
|
|
Bundle args = lastFragment.getArguments();
|
|
|
|
if (lastFragment instanceof ChatActivity && args != null) {
|
|
|
|
outState.putBundle("args", args);
|
|
|
|
outState.putString("fragment", "chat");
|
|
|
|
} else if (lastFragment instanceof SettingsActivity) {
|
|
|
|
outState.putString("fragment", "settings");
|
|
|
|
} else if (lastFragment instanceof GroupCreateFinalActivity && args != null) {
|
|
|
|
outState.putBundle("args", args);
|
|
|
|
outState.putString("fragment", "group");
|
2014-11-13 21:10:14 +01:00
|
|
|
} else if (lastFragment instanceof WallpapersActivity) {
|
2014-03-26 21:16:28 +01:00
|
|
|
outState.putString("fragment", "wallpapers");
|
2014-11-12 23:16:59 +01:00
|
|
|
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
|
2014-06-12 17:53:20 +02:00
|
|
|
outState.putBundle("args", args);
|
2014-06-04 01:31:48 +02:00
|
|
|
outState.putString("fragment", "chat_profile");
|
2015-09-24 22:52:02 +02:00
|
|
|
} else if (lastFragment instanceof ChannelCreateActivity && args != null && args.getInt("step") == 0) {
|
|
|
|
outState.putBundle("args", args);
|
|
|
|
outState.putString("fragment", "channel");
|
|
|
|
} else if (lastFragment instanceof ChannelEditActivity && args != null) {
|
|
|
|
outState.putBundle("args", args);
|
|
|
|
outState.putString("fragment", "edit");
|
2014-03-26 21:16:28 +01:00
|
|
|
}
|
|
|
|
lastFragment.saveSelfArgs(outState);
|
|
|
|
}
|
2013-12-20 20:25:49 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
}
|
2014-06-07 01:35:21 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
2015-02-26 02:32:51 +01:00
|
|
|
if (passcodeView.getVisibility() == View.VISIBLE) {
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
2014-06-07 01:35:21 +02:00
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
2015-02-26 02:32:51 +01:00
|
|
|
PhotoViewer.getInstance().closePhoto(true, false);
|
2014-11-07 21:10:12 +01:00
|
|
|
} else if (drawerLayoutContainer.isDrawerOpened()) {
|
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
} else if (AndroidUtilities.isTablet()) {
|
|
|
|
if (layersActionBarLayout.getVisibility() == View.VISIBLE) {
|
|
|
|
layersActionBarLayout.onBackPressed();
|
2014-09-24 04:17:27 +02:00
|
|
|
} else {
|
2014-11-07 21:10:12 +01:00
|
|
|
boolean cancel = false;
|
|
|
|
if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
BaseFragment lastFragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
|
|
|
cancel = !lastFragment.onBackPressed();
|
|
|
|
}
|
|
|
|
if (!cancel) {
|
|
|
|
actionBarLayout.onBackPressed();
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2014-11-07 21:10:12 +01:00
|
|
|
} else {
|
|
|
|
actionBarLayout.onBackPressed();
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLowMemory() {
|
|
|
|
super.onLowMemory();
|
|
|
|
actionBarLayout.onLowMemory();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
rightActionBarLayout.onLowMemory();
|
|
|
|
layersActionBarLayout.onLowMemory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActionModeStarted(ActionMode mode) {
|
|
|
|
super.onActionModeStarted(mode);
|
2015-10-29 18:10:07 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.onActionModeStarted(mode);
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
rightActionBarLayout.onActionModeStarted(mode);
|
|
|
|
layersActionBarLayout.onActionModeStarted(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActionModeFinished(ActionMode mode) {
|
|
|
|
super.onActionModeFinished(mode);
|
2015-10-29 18:10:07 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.onActionModeFinished(mode);
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
rightActionBarLayout.onActionModeFinished(mode);
|
|
|
|
layersActionBarLayout.onActionModeFinished(mode);
|
2014-06-07 01:35:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onPreIme() {
|
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
2015-02-26 02:32:51 +01:00
|
|
|
PhotoViewer.getInstance().closePhoto(true, false);
|
2014-06-07 01:35:21 +02:00
|
|
|
return true;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
return false;
|
2014-06-07 01:35:21 +02:00
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
|
2014-10-01 21:55:24 +02:00
|
|
|
@Override
|
2015-09-24 22:52:02 +02:00
|
|
|
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
|
2016-03-06 02:49:31 +01:00
|
|
|
if (keyCode == KeyEvent.KEYCODE_MENU && !UserConfig.isWaitingForPasscodeEnter) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (PhotoViewer.getInstance().isVisible()) {
|
|
|
|
return super.onKeyUp(keyCode, event);
|
|
|
|
}
|
2014-11-21 01:14:44 +01:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (layersActionBarLayout.getVisibility() == View.VISIBLE && !layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
layersActionBarLayout.onKeyUp(keyCode, event);
|
|
|
|
} else if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
rightActionBarLayout.onKeyUp(keyCode, event);
|
|
|
|
} else {
|
|
|
|
actionBarLayout.onKeyUp(keyCode, event);
|
|
|
|
}
|
2014-10-01 21:55:24 +02:00
|
|
|
} else {
|
2014-11-21 01:14:44 +01:00
|
|
|
if (actionBarLayout.fragmentsStack.size() == 1) {
|
|
|
|
if (!drawerLayoutContainer.isDrawerOpened()) {
|
2015-02-26 02:32:51 +01:00
|
|
|
if (getCurrentFocus() != null) {
|
|
|
|
AndroidUtilities.hideKeyboard(getCurrentFocus());
|
|
|
|
}
|
2014-11-21 01:14:44 +01:00
|
|
|
drawerLayoutContainer.openDrawer(false);
|
|
|
|
} else {
|
|
|
|
drawerLayoutContainer.closeDrawer(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
actionBarLayout.onKeyUp(keyCode, event);
|
|
|
|
}
|
2014-10-01 21:55:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.onKeyUp(keyCode, event);
|
|
|
|
}
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
@Override
|
|
|
|
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
2015-05-03 13:48:36 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
|
2015-07-22 20:56:37 +02:00
|
|
|
if (fragment instanceof DialogsActivity) {
|
|
|
|
DialogsActivity dialogsActivity = (DialogsActivity)fragment;
|
|
|
|
if (dialogsActivity.isMainDialogList() && layout != actionBarLayout) {
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.removeAllFragments();
|
2014-09-28 15:37:26 +02:00
|
|
|
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
|
2014-09-24 04:17:27 +02:00
|
|
|
layersActionBarLayout.removeAllFragments();
|
|
|
|
layersActionBarLayout.setVisibility(View.GONE);
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2014-09-25 05:54:35 +02:00
|
|
|
if (!tabletFullSize) {
|
|
|
|
shadowTabletSide.setVisibility(View.VISIBLE);
|
2014-09-28 15:37:26 +02:00
|
|
|
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
2014-09-25 05:54:35 +02:00
|
|
|
backgroundTablet.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-28 15:37:26 +02:00
|
|
|
}
|
|
|
|
if (fragment instanceof ChatActivity) {
|
2014-11-20 15:45:33 +01:00
|
|
|
if (!tabletFullSize && layout == rightActionBarLayout || tabletFullSize && layout == actionBarLayout) {
|
2015-01-23 22:59:15 +01:00
|
|
|
boolean result = !(tabletFullSize && layout == actionBarLayout && actionBarLayout.fragmentsStack.size() == 1);
|
2014-11-20 15:45:33 +01:00
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
|
|
|
}
|
2015-01-23 22:59:15 +01:00
|
|
|
if (!result) {
|
|
|
|
actionBarLayout.presentFragment(fragment, false, forceWithoutAnimation, false);
|
|
|
|
}
|
|
|
|
return result;
|
2014-11-20 15:45:33 +01:00
|
|
|
} else if (!tabletFullSize && layout != rightActionBarLayout) {
|
2014-09-24 04:17:27 +02:00
|
|
|
rightActionBarLayout.setVisibility(View.VISIBLE);
|
2014-09-25 05:54:35 +02:00
|
|
|
backgroundTablet.setVisibility(View.GONE);
|
2014-09-24 04:17:27 +02:00
|
|
|
rightActionBarLayout.removeAllFragments();
|
2014-09-28 15:37:26 +02:00
|
|
|
rightActionBarLayout.presentFragment(fragment, removeLast, true, false);
|
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
2014-09-30 00:48:11 +02:00
|
|
|
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
return false;
|
2014-09-25 05:54:35 +02:00
|
|
|
} else if (tabletFullSize && layout != actionBarLayout) {
|
2014-09-28 15:37:26 +02:00
|
|
|
actionBarLayout.presentFragment(fragment, actionBarLayout.fragmentsStack.size() > 1, forceWithoutAnimation, false);
|
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
2014-09-30 00:48:11 +02:00
|
|
|
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
2014-09-25 05:54:35 +02:00
|
|
|
}
|
|
|
|
return false;
|
2014-09-28 15:37:26 +02:00
|
|
|
} else {
|
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
2014-09-30 00:48:11 +02:00
|
|
|
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
|
|
|
}
|
2014-11-17 23:04:31 +01:00
|
|
|
actionBarLayout.presentFragment(fragment, actionBarLayout.fragmentsStack.size() > 1, forceWithoutAnimation, false);
|
|
|
|
return false;
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
} else if (layout != layersActionBarLayout) {
|
|
|
|
layersActionBarLayout.setVisibility(View.VISIBLE);
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, true);
|
2015-04-09 20:00:14 +02:00
|
|
|
if (fragment instanceof LoginActivity) {
|
2014-09-25 05:54:35 +02:00
|
|
|
backgroundTablet.setVisibility(View.VISIBLE);
|
|
|
|
shadowTabletSide.setVisibility(View.GONE);
|
2014-09-24 04:17:27 +02:00
|
|
|
shadowTablet.setBackgroundColor(0x00000000);
|
|
|
|
} else {
|
|
|
|
shadowTablet.setBackgroundColor(0x7F000000);
|
|
|
|
}
|
2014-09-28 15:37:26 +02:00
|
|
|
layersActionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
|
2014-09-24 04:17:27 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
2015-05-03 13:48:36 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity), false);
|
2014-09-24 04:17:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
2015-05-03 13:48:36 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
|
2015-07-22 20:56:37 +02:00
|
|
|
if (fragment instanceof DialogsActivity) {
|
|
|
|
DialogsActivity dialogsActivity = (DialogsActivity)fragment;
|
|
|
|
if (dialogsActivity.isMainDialogList() && layout != actionBarLayout) {
|
2014-09-24 04:17:27 +02:00
|
|
|
actionBarLayout.removeAllFragments();
|
|
|
|
actionBarLayout.addFragmentToStack(fragment);
|
|
|
|
layersActionBarLayout.removeAllFragments();
|
|
|
|
layersActionBarLayout.setVisibility(View.GONE);
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
2014-09-25 05:54:35 +02:00
|
|
|
if (!tabletFullSize) {
|
|
|
|
shadowTabletSide.setVisibility(View.VISIBLE);
|
2014-09-28 15:37:26 +02:00
|
|
|
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
2014-09-25 05:54:35 +02:00
|
|
|
backgroundTablet.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (fragment instanceof ChatActivity) {
|
2014-09-25 05:54:35 +02:00
|
|
|
if (!tabletFullSize && layout != rightActionBarLayout) {
|
2014-09-24 04:17:27 +02:00
|
|
|
rightActionBarLayout.setVisibility(View.VISIBLE);
|
2014-09-25 05:54:35 +02:00
|
|
|
backgroundTablet.setVisibility(View.GONE);
|
2014-09-24 04:17:27 +02:00
|
|
|
rightActionBarLayout.removeAllFragments();
|
|
|
|
rightActionBarLayout.addFragmentToStack(fragment);
|
2014-09-28 15:37:26 +02:00
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
layersActionBarLayout.closeLastFragment(true);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
return false;
|
2014-09-25 05:54:35 +02:00
|
|
|
} else if (tabletFullSize && layout != actionBarLayout) {
|
|
|
|
actionBarLayout.addFragmentToStack(fragment);
|
2014-09-28 15:37:26 +02:00
|
|
|
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
|
|
|
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
|
|
|
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
|
|
|
a--;
|
|
|
|
}
|
|
|
|
layersActionBarLayout.closeLastFragment(true);
|
|
|
|
}
|
2014-09-25 05:54:35 +02:00
|
|
|
return false;
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
} else if (layout != layersActionBarLayout) {
|
|
|
|
layersActionBarLayout.setVisibility(View.VISIBLE);
|
2015-03-19 00:09:45 +01:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(false, true);
|
2015-04-09 20:00:14 +02:00
|
|
|
if (fragment instanceof LoginActivity) {
|
2014-09-25 05:54:35 +02:00
|
|
|
backgroundTablet.setVisibility(View.VISIBLE);
|
|
|
|
shadowTabletSide.setVisibility(View.GONE);
|
2014-09-24 04:17:27 +02:00
|
|
|
shadowTablet.setBackgroundColor(0x00000000);
|
|
|
|
} else {
|
|
|
|
shadowTablet.setBackgroundColor(0x7F000000);
|
|
|
|
}
|
|
|
|
layersActionBarLayout.addFragmentToStack(fragment);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
2015-05-03 13:48:36 +02:00
|
|
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity), false);
|
2014-09-24 04:17:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean needCloseLastFragment(ActionBarLayout layout) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (layout == actionBarLayout && layout.fragmentsStack.size() <= 1) {
|
|
|
|
onFinish();
|
|
|
|
finish();
|
|
|
|
return false;
|
|
|
|
} else if (layout == rightActionBarLayout) {
|
2014-09-25 05:54:35 +02:00
|
|
|
if (!tabletFullSize) {
|
|
|
|
backgroundTablet.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2014-10-16 22:02:44 +02:00
|
|
|
} else if (layout == layersActionBarLayout && actionBarLayout.fragmentsStack.isEmpty() && layersActionBarLayout.fragmentsStack.size() == 1) {
|
2014-09-28 15:37:26 +02:00
|
|
|
onFinish();
|
|
|
|
finish();
|
|
|
|
return false;
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (layout.fragmentsStack.size() <= 1) {
|
|
|
|
onFinish();
|
|
|
|
finish();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRebuildAllFragments(ActionBarLayout layout) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (layout == layersActionBarLayout) {
|
|
|
|
rightActionBarLayout.rebuildAllFragmentViews(true);
|
|
|
|
rightActionBarLayout.showLastFragment();
|
|
|
|
actionBarLayout.rebuildAllFragmentViews(true);
|
|
|
|
actionBarLayout.showLastFragment();
|
|
|
|
}
|
|
|
|
}
|
2014-11-19 02:23:46 +01:00
|
|
|
drawerLayoutAdapter.notifyDataSetChanged();
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|