Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
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
xabber-android
Commits
1216bf06
Commit
1216bf06
authored
May 21, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/1.0.11'
parents
9f0d7c53
1a0e9810
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
75 deletions
+98
-75
build.gradle
app/build.gradle
+2
-2
AbstractChat.java
...in/java/com/xabber/android/data/message/AbstractChat.java
+12
-11
MessageNotificationCreator.java
...android/data/notification/MessageNotificationCreator.java
+9
-24
NotificationManager.java
...xabber/android/data/notification/NotificationManager.java
+51
-35
ChatViewerFragment.java
...c/main/java/com/xabber/android/ui/ChatViewerFragment.java
+20
-0
XMPPConnection.java
app/src/main/java/org/jivesoftware/smack/XMPPConnection.java
+1
-1
contact_list_drawer_account_item.xml
app/src/main/res/layout/contact_list_drawer_account_item.xml
+3
-2
No files found.
app/build.gradle
View file @
1216bf06
...
...
@@ -7,8 +7,8 @@ android {
defaultConfig
{
minSdkVersion
14
targetSdkVersion
22
versionCode
18
2
versionName
'1.0.1
0
'
versionCode
18
3
versionName
'1.0.1
1
'
}
compileOptions
{
...
...
app/src/main/java/com/xabber/android/data/message/AbstractChat.java
View file @
1216bf06
...
...
@@ -394,14 +394,7 @@ public abstract class AbstractChat extends BaseEntity {
openChat
();
if
(!
incoming
)
notify
=
false
;
if
(
notify
&&
!
notifyAboutMessage
())
notify
=
false
;
boolean
showTicker
=
notify
;
if
(
visible
&&
showTicker
)
{
notify
=
false
;
if
(!
ChatManager
.
getInstance
().
isNotifyVisible
(
account
,
user
))
showTicker
=
false
;
}
MessageItem
messageItem
=
new
MessageItem
(
this
,
record
?
null
:
NO_RECORD_TAG
,
resource
,
text
,
action
,
timestamp
,
delayTimestamp
,
incoming
,
read
,
send
,
false
,
incoming
,
...
...
@@ -412,9 +405,17 @@ public abstract class AbstractChat extends BaseEntity {
if
(
save
)
requestToWriteMessage
(
messageItem
,
resource
,
text
,
action
,
timestamp
,
delayTimestamp
,
incoming
,
read
,
send
);
if
(
showTicker
)
NotificationManager
.
getInstance
().
onMessageNotification
(
messageItem
,
notify
);
if
(
notify
&&
notifyAboutMessage
())
{
if
(
visible
)
{
if
(
ChatManager
.
getInstance
().
isNotifyVisible
(
account
,
user
))
{
NotificationManager
.
getInstance
().
onCurrentChatMessageNotification
(
messageItem
);
}
}
else
{
NotificationManager
.
getInstance
().
onMessageNotification
(
messageItem
);
}
}
MessageManager
.
getInstance
().
onChatChanged
(
account
,
user
,
incoming
);
return
messageItem
;
}
...
...
app/src/main/java/com/xabber/android/data/notification/MessageNotificationCreator.java
View file @
1216bf06
...
...
@@ -2,8 +2,6 @@ package com.xabber.android.data.notification;
import
android.app.PendingIntent
;
import
android.content.Intent
;
import
android.media.AudioManager
;
import
android.net.Uri
;
import
android.support.v4.app.NotificationCompat
;
import
android.text.Spannable
;
import
android.text.SpannableString
;
...
...
@@ -11,14 +9,13 @@ import android.text.style.StyleSpan;
import
com.xabber.android.R
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.android.data.extension.muc.MUCManager
;
import
com.xabber.android.data.message.MessageItem
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.data.message.phrase.PhraseManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.ChatViewer
;
import
com.xabber.android.ui.ContactList
;
import
com.xabber.android.ui.helper.AccountPainter
;
import
com.xabber.android.utils.StringUtils
;
...
...
@@ -26,10 +23,10 @@ import java.util.List;
public
class
MessageNotificationCreator
{
private
static
int
UNIQUE_REQUEST_CODE
=
0
;
private
final
Application
application
;
private
final
AccountPainter
accountPainter
;
private
List
<
MessageNotification
>
messageNotifications
;
private
NotificationCompat
.
Builder
notificationBuilder
;
public
MessageNotificationCreator
()
{
application
=
Application
.
getInstance
();
...
...
@@ -56,7 +53,7 @@ public class MessageNotificationCreator {
boolean
showText
=
ChatManager
.
getInstance
().
isShowText
(
message
.
getAccount
(),
message
.
getUser
());
notificationBuilder
=
new
NotificationCompat
.
Builder
(
application
);
NotificationCompat
.
Builder
notificationBuilder
=
new
NotificationCompat
.
Builder
(
application
);
notificationBuilder
.
setContentTitle
(
getTitle
(
message
,
messageCount
));
notificationBuilder
.
setContentText
(
getText
(
message
,
showText
));
notificationBuilder
.
setSubText
(
message
.
getAccount
());
...
...
@@ -75,7 +72,7 @@ public class MessageNotificationCreator {
notificationBuilder
.
setCategory
(
NotificationCompat
.
CATEGORY_MESSAGE
);
notificationBuilder
.
setPriority
(
NotificationCompat
.
PRIORITY_HIGH
);
addEffects
(
messageItem
);
NotificationManager
.
addEffects
(
notificationBuilder
,
messageItem
);
return
notificationBuilder
.
build
();
}
...
...
@@ -199,24 +196,12 @@ public class MessageNotificationCreator {
}
private
PendingIntent
getIntent
(
MessageNotification
message
)
{
Intent
chatIntent
=
ChatViewer
.
createClearTopIntent
(
application
,
message
.
getAccount
(),
message
.
getUser
()
);
Intent
backIntent
=
ContactList
.
createIntent
(
application
);
backIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
return
PendingIntent
.
getActivity
(
application
,
0
,
chatIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
Intent
intent
=
ChatViewer
.
createClearTopIntent
(
application
,
message
.
getAccount
(),
message
.
getUser
());
return
PendingIntent
.
getActivities
(
application
,
UNIQUE_REQUEST_CODE
++,
new
Intent
[]{
backIntent
,
intent
},
PendingIntent
.
FLAG_ONE_SHOT
);
}
private
void
addEffects
(
MessageItem
messageItem
)
{
if
(
messageItem
==
null
)
{
return
;
}
if
(
messageItem
.
getChat
().
getFirstNotification
()
||
!
SettingsManager
.
eventsFirstOnly
())
{
Uri
sound
=
PhraseManager
.
getInstance
().
getSound
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
(),
messageItem
.
getText
());
boolean
makeVibration
=
ChatManager
.
getInstance
().
isMakeVibro
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
());
NotificationManager
.
getInstance
().
setNotificationDefaults
(
notificationBuilder
,
makeVibration
,
sound
,
AudioManager
.
STREAM_NOTIFICATION
);
}
}
}
app/src/main/java/com/xabber/android/data/notification/NotificationManager.java
View file @
1216bf06
...
...
@@ -19,6 +19,7 @@ import android.app.PendingIntent;
import
android.content.Context
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.media.AudioManager
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.os.Vibrator
;
...
...
@@ -40,6 +41,8 @@ import com.xabber.android.data.account.OnAccountRemovedListener;
import
com.xabber.android.data.connection.ConnectionState
;
import
com.xabber.android.data.message.MessageItem
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.data.message.phrase.PhraseManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.ClearNotifications
;
import
com.xabber.android.ui.ContactList
;
...
...
@@ -64,6 +67,7 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan
public
static
final
int
PERSISTENT_NOTIFICATION_ID
=
1
;
public
static
final
int
MESSAGE_NOTIFICATION_ID
=
2
;
public
static
final
int
CURRENT_CHAT_MESSAGE_NOTIFICATION_ID
=
3
;
private
static
final
int
BASE_NOTIFICATION_PROVIDER_ID
=
0x10
;
private
static
final
long
VIBRATION_DURATION
=
500
;
...
...
@@ -153,6 +157,21 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan
return
instance
;
}
public
static
void
addEffects
(
NotificationCompat
.
Builder
notificationBuilder
,
MessageItem
messageItem
)
{
if
(
messageItem
==
null
)
{
return
;
}
if
(
messageItem
.
getChat
().
getFirstNotification
()
||
!
SettingsManager
.
eventsFirstOnly
())
{
Uri
sound
=
PhraseManager
.
getInstance
().
getSound
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
(),
messageItem
.
getText
());
boolean
makeVibration
=
ChatManager
.
getInstance
().
isMakeVibro
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
());
NotificationManager
.
getInstance
().
setNotificationDefaults
(
notificationBuilder
,
makeVibration
,
sound
,
AudioManager
.
STREAM_NOTIFICATION
);
}
}
private
void
initPersistentNotification
()
{
persistentNotificationBuilder
.
setContentTitle
(
application
.
getString
(
R
.
string
.
application_title_full
));
persistentNotificationBuilder
.
setDeleteIntent
(
clearNotifications
);
...
...
@@ -417,8 +436,6 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan
return
connectionState
;
}
private
void
notify
(
int
id
,
Notification
notification
)
{
LogManager
.
i
(
this
,
"Notification: "
+
id
+
", ticker: "
+
notification
.
tickerText
...
...
@@ -441,43 +458,42 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan
return
null
;
}
/**
* Shows ticker with the message and updates message notification.
*
* @param messageItem
* @param addNotification Whether notification should be stored.
*/
public
void
onMessageNotification
(
MessageItem
messageItem
,
boolean
addNotification
)
{
if
(
addNotification
)
{
MessageNotification
messageNotification
=
getMessageNotification
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
());
if
(
messageNotification
==
null
)
{
messageNotification
=
new
MessageNotification
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
(),
null
,
null
,
0
);
}
else
{
messageNotifications
.
remove
(
messageNotification
);
}
messageNotification
.
addMessage
(
messageItem
.
getText
());
messageNotifications
.
add
(
messageNotification
);
final
String
account
=
messageNotification
.
getAccount
();
final
String
user
=
messageNotification
.
getUser
();
final
String
text
=
messageNotification
.
getText
();
final
Date
timestamp
=
messageNotification
.
getTimestamp
();
final
int
count
=
messageNotification
.
getCount
();
if
(
AccountManager
.
getInstance
().
getArchiveMode
(
account
)
!=
ArchiveMode
.
dontStore
)
{
Application
.
getInstance
().
runInBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationTable
.
getInstance
().
write
(
account
,
user
,
text
,
timestamp
,
count
);
}
});
}
public
void
onMessageNotification
(
MessageItem
messageItem
)
{
MessageNotification
messageNotification
=
getMessageNotification
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
());
if
(
messageNotification
==
null
)
{
messageNotification
=
new
MessageNotification
(
messageItem
.
getChat
().
getAccount
(),
messageItem
.
getChat
().
getUser
(),
null
,
null
,
0
);
}
else
{
messageNotifications
.
remove
(
messageNotification
);
}
messageNotification
.
addMessage
(
messageItem
.
getText
());
messageNotifications
.
add
(
messageNotification
);
final
String
account
=
messageNotification
.
getAccount
();
final
String
user
=
messageNotification
.
getUser
();
final
String
text
=
messageNotification
.
getText
();
final
Date
timestamp
=
messageNotification
.
getTimestamp
();
final
int
count
=
messageNotification
.
getCount
();
if
(
AccountManager
.
getInstance
().
getArchiveMode
(
account
)
!=
ArchiveMode
.
dontStore
)
{
Application
.
getInstance
().
runInBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationTable
.
getInstance
().
write
(
account
,
user
,
text
,
timestamp
,
count
);
}
});
}
updateMessageNotification
(
messageItem
);
}
public
void
onCurrentChatMessageNotification
(
MessageItem
messageItem
)
{
NotificationCompat
.
Builder
notificationBuilder
=
new
NotificationCompat
.
Builder
(
application
);
addEffects
(
notificationBuilder
,
messageItem
);
notify
(
CURRENT_CHAT_MESSAGE_NOTIFICATION_ID
,
notificationBuilder
.
build
());
}
/**
* Updates message notification.
*/
...
...
app/src/main/java/com/xabber/android/ui/ChatViewerFragment.java
View file @
1216bf06
...
...
@@ -15,6 +15,7 @@ import android.text.TextWatcher;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -131,6 +132,8 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
}
});
setHasOptionsMenu
(
true
);
AccountPainter
accountPainter
=
new
AccountPainter
(
getActivity
());
toolbar
.
setBackgroundColor
(
accountPainter
.
getAccountMainColor
(
account
));
...
...
@@ -326,6 +329,23 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
updateChat
();
}
/**
* This method used for hardware menu button
*/
@Override
public
void
onCreateOptionsMenu
(
Menu
menu
,
MenuInflater
inflater
)
{
inflater
.
inflate
(
R
.
menu
.
chat
,
menu
);
setUpOptionsMenu
(
menu
);
}
/**
* This method used for hardware menu button
*/
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
return
onMenuItemClick
(
item
);
}
private
void
setUpOptionsMenu
(
Menu
menu
)
{
AbstractChat
abstractChat
=
MessageManager
.
getInstance
().
getChat
(
account
,
user
);
...
...
app/src/main/java/org/jivesoftware/smack/XMPPConnection.java
View file @
1216bf06
...
...
@@ -848,7 +848,7 @@ public class XMPPConnection extends Connection {
throw
new
IllegalStateException
();
context
.
init
(
kms
,
new
TrustManager
[]{
new
XMPPTrustManager
(
KeyStoreManager
.
getOrCreateKeyStore
(
config
),
get
Host
(),
config
.
getCertificateListener
(),
get
ServiceName
(),
config
.
getCertificateListener
(),
chainCheck
,
domainCheck
,
allowSelfSigned
)},
SECURE_RANDOM
);
}
Socket
plain
=
socket
;
...
...
app/src/main/res/layout/contact_list_drawer_account_item.xml
View file @
1216bf06
...
...
@@ -55,7 +55,7 @@
android:singleLine=
"true"
android:text=
"Some Name"
android:textColor=
"@color/green_700"
android:textSize=
"1
8
sp"
/>
android:textSize=
"1
6
sp"
/>
<TextView
android:id=
"@+id/account_jid"
...
...
@@ -79,6 +79,7 @@
android:gravity=
"top"
android:singleLine=
"true"
android:text=
"Online"
android:textColor=
"?android:attr/textColorSecondary"
/>
android:textColor=
"?android:attr/textColorSecondary"
android:textSize=
"14sp"
/>
</LinearLayout>
</LinearLayout>
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