Fixed app startup on Android 2.x, crash fixes
This commit is contained in:
parent
c1896e97c3
commit
2c61da0001
@ -82,7 +82,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 234
|
||||
versionCode 236
|
||||
versionName "1.4.15"
|
||||
}
|
||||
}
|
||||
|
@ -2655,6 +2655,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
showActionBar();
|
||||
|
||||
checkActionBarMenu();
|
||||
@ -2741,6 +2743,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
actionBarLayer.hideActionMode();
|
||||
hideEmojiPopup();
|
||||
paused = true;
|
||||
|
@ -371,6 +371,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
|
@ -177,6 +177,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
|
@ -358,16 +358,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
actionBarLayer.closeSearchField();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == MessagesController.contactsDidLoaded) {
|
||||
|
@ -245,16 +245,12 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
actionBarLayer.closeSearchField();
|
||||
}
|
||||
|
||||
public void search(final String query) {
|
||||
if (query == null) {
|
||||
searchResult = null;
|
||||
|
@ -194,6 +194,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ public class IdenticonActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
|
@ -197,16 +197,12 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
actionBarLayer.closeSearchField();
|
||||
}
|
||||
|
||||
public void search(final String query) {
|
||||
if (query == null) {
|
||||
searchResult = null;
|
||||
|
@ -120,13 +120,9 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
|
||||
if (fragmentsStack.isEmpty()) {
|
||||
if (!UserConfig.clientActivated) {
|
||||
LoginActivity fragment = new LoginActivity();
|
||||
fragment.onFragmentCreate();
|
||||
fragmentsStack.add(fragment);
|
||||
addFragmentToStack(new LoginActivity());
|
||||
} else {
|
||||
MessagesActivity fragment = new MessagesActivity(null);
|
||||
fragment.onFragmentCreate();
|
||||
fragmentsStack.add(fragment);
|
||||
addFragmentToStack(new MessagesActivity(null));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -137,37 +133,32 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
if (fragmentName.equals("chat")) {
|
||||
if (args != null) {
|
||||
ChatActivity chat = new ChatActivity(args);
|
||||
if (chat.onFragmentCreate()) {
|
||||
fragmentsStack.add(chat);
|
||||
if (addFragmentToStack(chat)) {
|
||||
chat.restoreSelfArgs(savedInstanceState);
|
||||
}
|
||||
}
|
||||
} else if (fragmentName.equals("settings")) {
|
||||
SettingsActivity settings = new SettingsActivity();
|
||||
settings.onFragmentCreate();
|
||||
addFragmentToStack(settings);
|
||||
settings.restoreSelfArgs(savedInstanceState);
|
||||
fragmentsStack.add(settings);
|
||||
} else if (fragmentName.equals("group")) {
|
||||
if (args != null) {
|
||||
GroupCreateFinalActivity group = new GroupCreateFinalActivity(args);
|
||||
if (group.onFragmentCreate()) {
|
||||
if (addFragmentToStack(group)) {
|
||||
group.restoreSelfArgs(savedInstanceState);
|
||||
fragmentsStack.add(group);
|
||||
}
|
||||
}
|
||||
} else if (fragmentName.equals("chat_profile")) {
|
||||
if (args != null) {
|
||||
ChatProfileActivity profile = new ChatProfileActivity(args);
|
||||
if (profile.onFragmentCreate()) {
|
||||
if (addFragmentToStack(profile)) {
|
||||
profile.restoreSelfArgs(savedInstanceState);
|
||||
fragmentsStack.add(profile);
|
||||
}
|
||||
}
|
||||
} else if (fragmentName.equals("wallpapers")) {
|
||||
SettingsWallpapersActivity settings = new SettingsWallpapersActivity();
|
||||
settings.onFragmentCreate();
|
||||
addFragmentToStack(settings);
|
||||
settings.restoreSelfArgs(savedInstanceState);
|
||||
fragmentsStack.add(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,6 +253,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -378,17 +378,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
showActionBar();
|
||||
if (messagesListViewAdapter != null) {
|
||||
messagesListViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
actionBarLayer.closeSearchField();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
|
@ -546,6 +546,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
showActionBar();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
@ -252,6 +252,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ public class SettingsChangeNameActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
|
@ -424,6 +424,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -436,6 +436,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -33,10 +33,6 @@ import android.widget.FrameLayout;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.GroupCreateFinalActivity;
|
||||
import org.telegram.ui.SettingsActivity;
|
||||
import org.telegram.ui.SettingsWallpapersActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -315,7 +311,7 @@ public class ActionBarActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (startedTracking || checkTransitionAnimation()) {
|
||||
if (startedTracking || checkTransitionAnimation() || fragmentsStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (actionBar.currentLayer != null && actionBar.currentLayer.isSearchFieldVisible) {
|
||||
@ -488,6 +484,15 @@ public class ActionBarActivity extends Activity {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addFragmentToStack(BaseFragment fragment) {
|
||||
if (!fragment.onFragmentCreate()) {
|
||||
return false;
|
||||
}
|
||||
fragment.setParentActivity(this);
|
||||
fragmentsStack.add(fragment);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void closeLastFragmentInternalRemoveOld(BaseFragment fragment) {
|
||||
fragment.onPause();
|
||||
fragment.onFragmentDestroy();
|
||||
@ -566,9 +571,6 @@ public class ActionBarActivity extends Activity {
|
||||
}
|
||||
|
||||
public void removeFragmentFromStack(BaseFragment fragment) {
|
||||
// if (!fragmentsStack.isEmpty() && fragmentsStack.get(fragmentsStack.size() - 1) == fragment) {
|
||||
// return;
|
||||
// }
|
||||
fragment.onFragmentDestroy();
|
||||
fragment.setParentActivity(null);
|
||||
fragmentsStack.remove(fragment);
|
||||
|
@ -437,4 +437,10 @@ public class ActionBarLayer extends FrameLayout {
|
||||
menu.onMenuButtonPressed();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPause() {
|
||||
if (menu != null) {
|
||||
menu.hideAllPopupMenus();
|
||||
}
|
||||
}
|
||||
}
|
@ -87,7 +87,7 @@ public class ActionBarMenu extends LinearLayout {
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
public void hideAllPopupMenus() {
|
||||
for (int a = 0; a < getChildCount(); a++) {
|
||||
View view = getChildAt(a);
|
||||
if (view instanceof ActionBarMenuItem) {
|
||||
|
@ -23,7 +23,6 @@ import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.R;
|
||||
@ -41,7 +40,7 @@ public class ActionBarMenuItem extends ImageView {
|
||||
|
||||
private LinearLayout popupLayout;
|
||||
private ActionBarMenu parentMenu;
|
||||
private PopupWindow popupWindow;
|
||||
private ActionBarPopupWindow popupWindow;
|
||||
private ActionBar parentActionBar;
|
||||
private EditText searchField;
|
||||
private boolean isSearchField = false;
|
||||
@ -120,12 +119,12 @@ public class ActionBarMenuItem extends ImageView {
|
||||
return;
|
||||
}
|
||||
if (popupWindow == null) {
|
||||
popupWindow = new PopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
popupWindow = new ActionBarPopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
popupWindow.setFocusable(true);
|
||||
popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setClippingEnabled(true);
|
||||
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
||||
}
|
||||
if (popupLayout.getMeasuredWidth() == 0) {
|
||||
@ -177,7 +176,6 @@ public class ActionBarMenuItem extends ImageView {
|
||||
searchField.setTextSize(18);
|
||||
searchField.setTextColor(0xffffffff);
|
||||
searchField.setSingleLine(true);
|
||||
searchField.setTextIsSelectable(false);
|
||||
searchField.setBackgroundResource(R.drawable.search_light_states);
|
||||
searchField.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
|
||||
searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
@ -220,10 +218,11 @@ public class ActionBarMenuItem extends ImageView {
|
||||
mCursorDrawableRes.setAccessible(true);
|
||||
mCursorDrawableRes.set(searchField, R.drawable.search_carret);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//nothing to do
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
searchField.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_ACTION_SEARCH);
|
||||
searchField.setTextIsSelectable(false);
|
||||
} else {
|
||||
searchField.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
||||
}
|
||||
|
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
//Thanks to https://github.com/JakeWharton/ActionBarSherlock/
|
||||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ActionBarPopupWindow extends PopupWindow {
|
||||
private static final Field superListenerField;
|
||||
static {
|
||||
Field f = null;
|
||||
try {
|
||||
f = PopupWindow.class.getDeclaredField("mOnScrollChangedListener");
|
||||
f.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
/* ignored */
|
||||
}
|
||||
superListenerField = f;
|
||||
}
|
||||
|
||||
private static final ViewTreeObserver.OnScrollChangedListener NOP = new ViewTreeObserver.OnScrollChangedListener() {
|
||||
@Override
|
||||
public void onScrollChanged() {
|
||||
/* do nothing */
|
||||
}
|
||||
};
|
||||
|
||||
private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener;
|
||||
private ViewTreeObserver mViewTreeObserver;
|
||||
|
||||
public ActionBarPopupWindow() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(int width, int height) {
|
||||
super(width, height);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(View contentView) {
|
||||
super(contentView);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(View contentView, int width, int height, boolean focusable) {
|
||||
super(contentView, width, height, focusable);
|
||||
init();
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow(View contentView, int width, int height) {
|
||||
super(contentView, width, height);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (superListenerField != null) {
|
||||
try {
|
||||
mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this);
|
||||
superListenerField.set(this, NOP);
|
||||
} catch (Exception e) {
|
||||
mSuperScrollListener = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterListener() {
|
||||
// Don't do anything if we haven't managed to patch the super listener
|
||||
if (mSuperScrollListener != null && mViewTreeObserver != null) {
|
||||
if (mViewTreeObserver.isAlive()) {
|
||||
mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
|
||||
}
|
||||
mViewTreeObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void registerListener(View anchor) {
|
||||
// Don't do anything if we haven't managed to patch the super listener.
|
||||
// And don't bother attaching the listener if the anchor view isn't
|
||||
// attached. This means we'll only have to deal with the real VTO owned
|
||||
// by the ViewRoot.
|
||||
if (mSuperScrollListener != null) {
|
||||
ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver()
|
||||
: null;
|
||||
if (vto != mViewTreeObserver) {
|
||||
if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) {
|
||||
mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
|
||||
}
|
||||
if ((mViewTreeObserver = vto) != null) {
|
||||
vto.addOnScrollChangedListener(mSuperScrollListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAsDropDown(View anchor, int xoff, int yoff) {
|
||||
super.showAsDropDown(anchor, xoff, yoff);
|
||||
registerListener(anchor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(View anchor, int xoff, int yoff, int width, int height) {
|
||||
super.update(anchor, xoff, yoff, width, height);
|
||||
registerListener(anchor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(View anchor, int width, int height) {
|
||||
super.update(anchor, width, height);
|
||||
registerListener(anchor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAtLocation(View parent, int gravity, int x, int y) {
|
||||
super.showAtLocation(parent, gravity, x, y);
|
||||
unregisterListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
unregisterListener();
|
||||
}
|
||||
}
|
@ -51,11 +51,11 @@ public class BaseFragment {
|
||||
}
|
||||
fragmentView = null;
|
||||
}
|
||||
if (actionBarLayer != null) {
|
||||
actionBarLayer.onDestroy();
|
||||
actionBarLayer = null;
|
||||
}
|
||||
if (parentActivity != null) {
|
||||
if (actionBarLayer != null) {
|
||||
actionBarLayer.onDestroy();
|
||||
actionBarLayer = null;
|
||||
}
|
||||
actionBarLayer = parentActivity.getInternalActionBar().createLayer();
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,10 @@ public class BaseFragment {
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
|
||||
if (actionBarLayer != null) {
|
||||
actionBarLayer.onPause();
|
||||
actionBarLayer.closeSearchField();
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="android:windowBackground">@android:color/white</item>
|
||||
<item name="android:windowContentOverlay">@drawable/shadow</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.TMessages" parent="@android:style/Theme.Holo.Light">
|
||||
|
Loading…
Reference in New Issue
Block a user