Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apk
Commits
172ded5e
Commit
172ded5e
authored
Jul 10, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIxed android 2.x crashes
parent
d9b9a721
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
40 deletions
+48
-40
ConnectionsManager.java
.../main/java/org/telegram/messenger/ConnectionsManager.java
+23
-9
PopupNotificationActivity.java
.../main/java/org/telegram/ui/PopupNotificationActivity.java
+25
-31
No files found.
TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
View file @
172ded5e
...
...
@@ -214,6 +214,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
PowerManager
pm
=
(
PowerManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Context
.
POWER_SERVICE
);
wakeLock
=
pm
.
newWakeLock
(
PowerManager
.
PARTIAL_WAKE_LOCK
,
"lock"
);
wakeLock
.
setReferenceCounted
(
false
);
}
public
int
getConnectionState
()
{
...
...
@@ -2074,10 +2075,15 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
else
{
if
(
resultContainer
.
result
instanceof
TLRPC
.
updates_Difference
)
{
pushMessagesReceived
=
true
;
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
}
});
}
request
.
completionBlock
.
run
(
resultContainer
.
result
,
null
);
}
}
...
...
@@ -2250,15 +2256,23 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if
(
paused
)
{
pushMessagesReceived
=
false
;
}
if
(!
wakeLock
.
isHeld
())
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
wakeLock
.
acquire
(
20000
);
}
});
resumeNetworkInternal
();
}
else
{
pushMessagesReceived
=
true
;
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
}
});
MessagesController
.
getInstance
().
processUpdates
((
TLRPC
.
Updates
)
message
,
false
);
}
}
else
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java
View file @
172ded5e
...
...
@@ -19,6 +19,7 @@ import android.os.Bundle;
import
android.os.PowerManager
;
import
android.util.AttributeSet
;
import
android.util.TypedValue
;
import
android.view.Gravity
;
import
android.view.MotionEvent
;
import
android.view.VelocityTracker
;
import
android.view.View
;
...
...
@@ -50,6 +51,7 @@ import org.telegram.ui.Views.ActionBar.ActionBarLayer;
import
org.telegram.ui.Views.ActionBar.ActionBarMenu
;
import
org.telegram.ui.Views.BackupImageView
;
import
org.telegram.ui.Views.ChatActivityEnterView
;
import
org.telegram.ui.Views.FrameLayoutFixed
;
import
org.telegram.ui.Views.PopupAudioView
;
import
java.io.File
;
...
...
@@ -85,9 +87,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
private
float
moveStartX
=
-
1
;
private
boolean
startedMoving
=
false
;
private
Runnable
onAnimationEndRunnable
=
null
;
private
Runnable
wakeLockRunnable
=
null
;
private
class
FrameLayoutTouch
extends
FrameLayout
{
private
class
FrameLayoutTouch
extends
FrameLayout
Fixed
{
public
FrameLayoutTouch
(
Context
context
)
{
super
(
context
);
}
...
...
@@ -117,7 +118,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
}
public
class
FrameLayoutAnimationListener
extends
FrameLayout
{
public
class
FrameLayoutAnimationListener
extends
FrameLayout
Fixed
{
public
FrameLayoutAnimationListener
(
Context
context
)
{
super
(
context
);
}
...
...
@@ -215,6 +216,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
PowerManager
pm
=
(
PowerManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Context
.
POWER_SERVICE
);
wakeLock
=
pm
.
newWakeLock
(
PowerManager
.
SCREEN_DIM_WAKE_LOCK
|
PowerManager
.
ACQUIRE_CAUSES_WAKEUP
,
"screen"
);
wakeLock
.
setReferenceCounted
(
false
);
handleIntent
(
getIntent
());
}
...
...
@@ -305,7 +307,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
}
else
if
(
motionEvent
==
null
||
motionEvent
.
getAction
()
==
MotionEvent
.
ACTION_UP
||
motionEvent
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
if
(
motionEvent
!=
null
&&
startedMoving
)
{
ViewGroup
.
MarginLayoutParams
layoutParams
=
(
ViewGroup
.
Margin
LayoutParams
)
centerView
.
getLayoutParams
();
FrameLayout
.
LayoutParams
layoutParams
=
(
FrameLayout
.
LayoutParams
)
centerView
.
getLayoutParams
();
int
diff
=
(
int
)(
motionEvent
.
getX
()
-
moveStartX
);
int
width
=
AndroidUtilities
.
displaySize
.
x
-
AndroidUtilities
.
dp
(
24
);
int
moveDiff
=
0
;
...
...
@@ -380,24 +382,27 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
private
void
applyViewsLayoutParams
(
int
xOffset
)
{
ViewGroup
.
Margin
LayoutParams
layoutParams
=
null
;
FrameLayout
.
LayoutParams
layoutParams
=
null
;
int
widht
=
AndroidUtilities
.
displaySize
.
x
-
AndroidUtilities
.
dp
(
24
);
if
(
leftView
!=
null
)
{
layoutParams
=
(
ViewGroup
.
MarginLayoutParams
)
leftView
.
getLayoutParams
();
layoutParams
=
(
FrameLayout
.
LayoutParams
)
leftView
.
getLayoutParams
();
layoutParams
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
widht
;
layoutParams
.
leftMargin
=
-
widht
+
xOffset
;
leftView
.
setLayoutParams
(
layoutParams
);
}
if
(
centerView
!=
null
)
{
layoutParams
=
(
ViewGroup
.
MarginLayoutParams
)
centerView
.
getLayoutParams
();
layoutParams
=
(
FrameLayout
.
LayoutParams
)
centerView
.
getLayoutParams
();
layoutParams
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
widht
;
layoutParams
.
leftMargin
=
xOffset
;
centerView
.
setLayoutParams
(
layoutParams
);
}
if
(
rightView
!=
null
)
{
layoutParams
=
(
ViewGroup
.
MarginLayoutParams
)
rightView
.
getLayoutParams
();
layoutParams
=
(
FrameLayout
.
LayoutParams
)
rightView
.
getLayoutParams
();
layoutParams
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
widht
;
layoutParams
.
leftMargin
=
widht
+
xOffset
;
...
...
@@ -523,7 +528,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if
(
applyOffset
)
{
int
widht
=
AndroidUtilities
.
displaySize
.
x
-
AndroidUtilities
.
dp
(
24
);
ViewGroup
.
MarginLayoutParams
layoutParams
=
(
ViewGroup
.
MarginLayoutParams
)
view
.
getLayoutParams
();
FrameLayout
.
LayoutParams
layoutParams
=
(
FrameLayout
.
LayoutParams
)
view
.
getLayoutParams
();
layoutParams
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
widht
;
if
(
num
==
currentMessageNum
)
{
...
...
@@ -581,11 +587,12 @@ public class PopupNotificationActivity extends Activity implements NotificationC
rightView
=
getViewForMessage
(
currentMessageNum
+
1
,
true
);
}
else
if
(
move
==
3
)
{
if
(
rightView
!=
null
)
{
int
offset
=
((
ViewGroup
.
Margin
LayoutParams
)
rightView
.
getLayoutParams
()).
leftMargin
;
int
offset
=
((
FrameLayout
.
LayoutParams
)
rightView
.
getLayoutParams
()).
leftMargin
;
reuseView
(
rightView
);
rightView
=
getViewForMessage
(
currentMessageNum
+
1
,
false
);
int
widht
=
AndroidUtilities
.
displaySize
.
x
-
AndroidUtilities
.
dp
(
24
);
ViewGroup
.
MarginLayoutParams
layoutParams
=
(
ViewGroup
.
MarginLayoutParams
)
rightView
.
getLayoutParams
();
FrameLayout
.
LayoutParams
layoutParams
=
(
FrameLayout
.
LayoutParams
)
rightView
.
getLayoutParams
();
layoutParams
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
widht
;
layoutParams
.
leftMargin
=
offset
;
...
...
@@ -594,11 +601,12 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
}
else
if
(
move
==
4
)
{
if
(
leftView
!=
null
)
{
int
offset
=
((
ViewGroup
.
Margin
LayoutParams
)
leftView
.
getLayoutParams
()).
leftMargin
;
int
offset
=
((
FrameLayout
.
LayoutParams
)
leftView
.
getLayoutParams
()).
leftMargin
;
reuseView
(
leftView
);
leftView
=
getViewForMessage
(
0
,
false
);
int
widht
=
AndroidUtilities
.
displaySize
.
x
-
AndroidUtilities
.
dp
(
24
);
ViewGroup
.
MarginLayoutParams
layoutParams
=
(
ViewGroup
.
MarginLayoutParams
)
leftView
.
getLayoutParams
();
FrameLayout
.
LayoutParams
layoutParams
=
(
FrameLayout
.
LayoutParams
)
leftView
.
getLayoutParams
();
layoutParams
.
gravity
=
Gravity
.
TOP
|
Gravity
.
LEFT
;
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
widht
;
layoutParams
.
leftMargin
=
offset
;
...
...
@@ -651,21 +659,6 @@ public class PopupNotificationActivity extends Activity implements NotificationC
currentMessageNum
=
0
;
}
getNewMessage
();
wakeLock
.
acquire
();
Utilities
.
stageQueue
.
postRunnable
(
wakeLockRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
wakeLockRunnable
=
null
;
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
}
});
}
},
7000
);
}
private
void
getNewMessage
()
{
...
...
@@ -868,6 +861,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
}
ConnectionsManager
.
getInstance
().
setAppPaused
(
false
,
false
);
fixLayout
();
wakeLock
.
acquire
(
7000
);
}
@Override
...
...
@@ -879,6 +873,9 @@ public class PopupNotificationActivity extends Activity implements NotificationC
chatActivityEnterView
.
setFieldFocused
(
false
);
}
ConnectionsManager
.
getInstance
().
setAppPaused
(
true
,
false
);
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
}
@Override
...
...
@@ -972,8 +969,5 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
if
(
wakeLockRunnable
!=
null
)
{
Utilities
.
stageQueue
.
cancelRunnable
(
wakeLockRunnable
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment