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
a27f770f
Commit
a27f770f
authored
Jul 10, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/smack
parents
640ff058
1fa84b15
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
180 additions
and
6 deletions
+180
-6
DatabaseManager.java
...rc/main/java/com/xabber/android/data/DatabaseManager.java
+1
-1
SettingsManager.java
...rc/main/java/com/xabber/android/data/SettingsManager.java
+5
-0
RoomChat.java
.../java/com/xabber/android/data/extension/muc/RoomChat.java
+11
-1
ChatManager.java
...ava/com/xabber/android/data/message/chat/ChatManager.java
+45
-2
Suppress100Table.java
...om/xabber/android/data/message/chat/Suppress100Table.java
+62
-0
AccountEditorFragment.java
.../xabber/android/ui/preferences/AccountEditorFragment.java
+23
-1
ChatContactSettingsFragment.java
...r/android/ui/preferences/ChatContactSettingsFragment.java
+5
-0
account_editor.xml
app/src/main/res/values/account_editor.xml
+4
-1
preference_editor.xml
app/src/main/res/values/preference_editor.xml
+1
-0
preferences.xml
app/src/main/res/values/preferences.xml
+4
-0
account_editor_oauth.xml
app/src/main/res/xml/account_editor_oauth.xml
+6
-0
account_editor_xmpp.xml
app/src/main/res/xml/account_editor_xmpp.xml
+9
-0
preference_chat_contact.xml
app/src/main/res/xml/preference_chat_contact.xml
+4
-0
No files found.
app/src/main/java/com/xabber/android/data/DatabaseManager.java
View file @
a27f770f
...
...
@@ -38,7 +38,7 @@ public class DatabaseManager extends SQLiteOpenHelper implements
OnLoadListener
,
OnClearListener
{
private
static
final
String
DATABASE_NAME
=
"xabber.db"
;
private
static
final
int
DATABASE_VERSION
=
6
7
;
private
static
final
int
DATABASE_VERSION
=
6
8
;
private
static
final
SQLiteException
DOWNGRAD_EXCEPTION
=
new
SQLiteException
(
"Database file was deleted"
);
...
...
app/src/main/java/com/xabber/android/data/SettingsManager.java
View file @
a27f770f
...
...
@@ -227,6 +227,11 @@ public class SettingsManager implements OnInitializedListener,
R
.
bool
.
events_vibro_default
);
}
public
static
boolean
eventsSuppress100
()
{
return
getBoolean
(
R
.
string
.
chat_events_suppress_100_key
,
R
.
bool
.
chat_events_suppress_100_default
);
}
public
static
boolean
eventsIgnoreSystemVibro
()
{
return
getBoolean
(
R
.
string
.
events_ignore_system_vibro_key
,
R
.
bool
.
events_ignore_system_vibro_default
);
...
...
app/src/main/java/com/xabber/android/data/extension/muc/RoomChat.java
View file @
a27f770f
...
...
@@ -22,6 +22,7 @@ import com.xabber.android.data.account.StatusMode;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.ChatAction
;
import
com.xabber.android.data.message.MessageItem
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.xmpp.address.Jid
;
import
com.xabber.xmpp.delay.Delay
;
...
...
@@ -200,6 +201,11 @@ public class RoomChat extends AbstractChat {
onInvitationDeclined
(
mucUser
.
getDecline
().
getFrom
(),
mucUser
.
getDecline
().
getReason
());
return
true
;
}
if
(
mucUser
!=
null
&&
mucUser
.
getStatus
()
!=
null
&&
mucUser
.
getStatus
().
getCode
().
equals
(
"100"
)
&&
ChatManager
.
getInstance
().
isSuppress100
(
account
,
user
))
{
// 'This room is not anonymous'
return
true
;
}
final
String
text
=
message
.
getBody
();
final
String
subject
=
message
.
getSubject
();
if
(
text
==
null
&&
subject
==
null
)
{
...
...
@@ -216,8 +222,12 @@ public class RoomChat extends AbstractChat {
RosterManager
.
getInstance
().
onContactChanged
(
account
,
bareAddress
);
newAction
(
resource
,
subject
,
ChatAction
.
subject
);
}
else
{
boolean
notify
=
true
;
String
packetID
=
message
.
getPacketID
();
Date
delay
=
Delay
.
getDelay
(
message
);
if
(
delay
!=
null
)
{
notify
=
false
;
}
for
(
MessageItem
messageItem
:
messages
)
{
// Search for duplicates
if
(
packetID
!=
null
&&
packetID
.
equals
(
messageItem
.
getPacketID
()))
{
...
...
@@ -233,7 +243,7 @@ public class RoomChat extends AbstractChat {
}
updateThreadId
(
message
.
getThread
());
MessageItem
messageItem
=
newMessage
(
resource
,
text
,
null
,
delay
,
true
,
true
,
false
,
false
,
true
);
delay
,
true
,
notify
,
false
,
false
,
true
);
messageItem
.
setPacketID
(
packetID
);
}
}
else
if
(
packet
instanceof
Presence
)
{
...
...
app/src/main/java/com/xabber/android/data/message/chat/ChatManager.java
View file @
a27f770f
...
...
@@ -71,6 +71,10 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
* Sound, associated with chat for user in account.
*/
private
final
NestedMap
<
Uri
>
sounds
;
/**
* Whether 'This room is not anonymous'-messages (Status Code 100) should be suppressed
*/
private
final
NestedMap
<
Boolean
>
suppress100
;
private
ChatManager
()
{
chatInputs
=
new
NestedMap
<
ChatInput
>();
...
...
@@ -79,6 +83,7 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
showText
=
new
NestedMap
<>();
makeVibro
=
new
NestedMap
<
Boolean
>();
notifyVisible
=
new
NestedMap
<
Boolean
>();
suppress100
=
new
NestedMap
<
Boolean
>();
}
public
static
ChatManager
getInstance
()
{
...
...
@@ -92,6 +97,7 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
final
NestedMap
<
ShowMessageTextInNotification
>
showText
=
new
NestedMap
<>();
final
NestedMap
<
Boolean
>
makeVibro
=
new
NestedMap
<
Boolean
>();
final
NestedMap
<
Uri
>
sounds
=
new
NestedMap
<
Uri
>();
final
NestedMap
<
Boolean
>
suppress100
=
new
NestedMap
<
Boolean
>();
Cursor
cursor
;
cursor
=
PrivateChatTable
.
getInstance
().
list
();
try
{
...
...
@@ -158,18 +164,31 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
cursor
.
close
();
}
cursor
=
Suppress100Table
.
getInstance
().
list
();
try
{
if
(
cursor
.
moveToFirst
())
{
do
{
makeVibro
.
put
(
Suppress100Table
.
getAccount
(
cursor
),
Suppress100Table
.
getUser
(
cursor
),
Suppress100Table
.
getValue
(
cursor
));
}
while
(
cursor
.
moveToNext
());
}
}
finally
{
cursor
.
close
();
}
Application
.
getInstance
().
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onLoaded
(
privateChats
,
notifyVisible
,
showText
,
makeVibro
,
sounds
);
sounds
,
suppress100
);
}
});
}
private
void
onLoaded
(
Set
<
BaseEntity
>
privateChats
,
NestedMap
<
Boolean
>
notifyVisible
,
NestedMap
<
ShowMessageTextInNotification
>
showText
,
NestedMap
<
Boolean
>
vibro
,
NestedMap
<
Uri
>
sounds
)
{
NestedMap
<
Boolean
>
vibro
,
NestedMap
<
Uri
>
sounds
,
NestedMap
<
Boolean
>
suppress100
)
{
for
(
BaseEntity
baseEntity
:
privateChats
)
this
.
privateChats
.
put
(
baseEntity
.
getAccount
(),
baseEntity
.
getUser
(),
PRIVATE_CHAT
);
...
...
@@ -177,6 +196,7 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
this
.
showText
.
addAll
(
showText
);
this
.
makeVibro
.
addAll
(
vibro
);
this
.
sounds
.
addAll
(
sounds
);
this
.
suppress100
.
addAll
(
suppress100
);
}
@Override
...
...
@@ -187,6 +207,7 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
showText
.
clear
(
accountItem
.
getAccount
());
makeVibro
.
clear
(
accountItem
.
getAccount
());
notifyVisible
.
clear
(
accountItem
.
getAccount
());
suppress100
.
clear
(
accountItem
.
getAccount
());
}
/**
...
...
@@ -391,4 +412,26 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
});
}
/**
* @param account
* @param user
* @return Whether 'This Room is not Anonymous'-messages (Status Code 100) should be suppressed.
*/
public
boolean
isSuppress100
(
String
account
,
String
user
)
{
Boolean
value
=
suppress100
.
get
(
account
,
user
);
if
(
value
==
null
)
return
SettingsManager
.
eventsSuppress100
();
return
value
;
}
public
void
setSuppress100
(
final
String
account
,
final
String
user
,
final
boolean
value
)
{
suppress100
.
put
(
account
,
user
,
value
);
Application
.
getInstance
().
runInBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
Suppress100Table
.
getInstance
().
write
(
account
,
user
,
value
);
}
});
}
}
app/src/main/java/com/xabber/android/data/message/chat/Suppress100Table.java
0 → 100644
View file @
a27f770f
package
com
.
xabber
.
android
.
data
.
message
.
chat
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteStatement
;
import
com.xabber.android.data.DatabaseManager
;
/**
* Storage with suppress100 settings for each chat.
* @author <a href="mailto:jaro.fietz@uniscon.de">Jaro Fietz</a>.
*/
class
Suppress100Table
extends
AbstractChatPropertyTable
<
Boolean
>
{
static
final
String
NAME
=
"chat_suppress_100"
;
private
final
static
Suppress100Table
instance
;
static
{
instance
=
new
Suppress100Table
(
DatabaseManager
.
getInstance
());
DatabaseManager
.
getInstance
().
addTable
(
instance
);
}
public
static
Suppress100Table
getInstance
()
{
return
instance
;
}
private
Suppress100Table
(
DatabaseManager
databaseManager
)
{
super
(
databaseManager
);
}
@Override
protected
String
getTableName
()
{
return
NAME
;
}
@Override
String
getValueType
()
{
return
"INTEGER"
;
}
@Override
void
bindValue
(
SQLiteStatement
writeStatement
,
Boolean
value
)
{
writeStatement
.
bindLong
(
3
,
value
?
1
:
0
);
}
@Override
public
void
migrate
(
SQLiteDatabase
db
,
int
toVersion
)
{
super
.
migrate
(
db
,
toVersion
);
switch
(
toVersion
)
{
case
68
:
initialMigrate
(
db
,
NAME
,
"INTEGER"
);
break
;
default
:
break
;
}
}
static
boolean
getValue
(
Cursor
cursor
)
{
return
cursor
.
getLong
(
cursor
.
getColumnIndex
(
Fields
.
VALUE
))
!=
0
;
}
}
app/src/main/java/com/xabber/android/ui/preferences/AccountEditorFragment.java
View file @
a27f770f
...
...
@@ -61,7 +61,13 @@ public class AccountEditorFragment extends BaseSettingsFragment
if
(
getString
(
R
.
string
.
account_port_key
).
equals
(
key
))
{
try
{
Integer
.
parseInt
((
String
)
newValue
);
int
newPort
=
Integer
.
parseInt
((
String
)
newValue
);
// TODO: Not IPv6 Compatible
if
(
newPort
<
0
||
newPort
>
0xFFFF
)
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
account_invalid_port_range
),
Toast
.
LENGTH_LONG
).
show
();
return
false
;
}
}
catch
(
NumberFormatException
e
)
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
account_invalid_port
),
Toast
.
LENGTH_LONG
).
show
();
...
...
@@ -69,6 +75,22 @@ public class AccountEditorFragment extends BaseSettingsFragment
}
}
if
(
getString
(
R
.
string
.
account_proxy_port_key
).
equals
(
key
))
{
try
{
int
newPort
=
Integer
.
parseInt
((
String
)
newValue
);
// TODO: Not IPv6 Compatible
if
(
newPort
<
0
||
newPort
>
0xFFFF
)
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
account_proxy_invalid_port_range
),
Toast
.
LENGTH_LONG
).
show
();
return
false
;
}
}
catch
(
NumberFormatException
e
)
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
account_proxy_invalid_port
),
Toast
.
LENGTH_LONG
).
show
();
return
false
;
}
}
if
(
getString
(
R
.
string
.
account_tls_mode_key
).
equals
(
key
)
||
getString
(
R
.
string
.
account_archive_mode_key
).
equals
(
key
)
||
getString
(
R
.
string
.
account_proxy_type_key
).
equals
(
key
)
...
...
app/src/main/java/com/xabber/android/ui/preferences/ChatContactSettingsFragment.java
View file @
a27f770f
...
...
@@ -53,6 +53,8 @@ public class ChatContactSettingsFragment extends BaseSettingsFragment {
.
isMakeVibro
(
account
,
user
));
putValue
(
map
,
R
.
string
.
chat_events_sound_key
,
ChatManager
.
getInstance
()
.
getSound
(
account
,
user
));
putValue
(
map
,
R
.
string
.
chat_events_suppress_100_key
,
ChatManager
.
getInstance
()
.
isSuppress100
(
account
,
user
));
return
map
;
}
...
...
@@ -82,6 +84,9 @@ public class ChatContactSettingsFragment extends BaseSettingsFragment {
ChatManager
.
getInstance
().
setSound
(
account
,
user
,
getUri
(
result
,
R
.
string
.
chat_events_sound_key
));
if
(
hasChanges
(
source
,
result
,
R
.
string
.
chat_events_suppress_100_key
))
ChatManager
.
getInstance
().
setSuppress100
(
account
,
user
,
getBoolean
(
result
,
R
.
string
.
chat_events_suppress_100_key
));
return
true
;
}
...
...
app/src/main/res/values/account_editor.xml
View file @
a27f770f
...
...
@@ -28,11 +28,14 @@
<string
name=
"account_custom_summary"
>
Use custom host settings instead of SRV record
</string>
<string
name=
"account_enabled_summary"
>
Check to enable account
</string>
<string
name=
"account_invalid_port"
>
Port must be a number (default: 5222)
</string>
<string
name=
"account_invalid_priority"
>
Priority value must be a number between -128 and 128 (default: 10)
</string>
<string
name=
"account_invalid_port_range"
>
Port must be between 1 and 65535 (default: 5222)
</string>
<string
name=
"account_invalid_priority"
>
Priority value must be a number between -128 and 128 (default: 0)
</string>
<string
name=
"account_oauth"
>
Authorization
</string>
<string
name=
"account_oauth_invalidated"
>
Not authorized
</string>
<string
name=
"account_oauth_summary"
>
OAuth settings
</string>
<string
name=
"account_proxy_host"
>
Proxy host
</string>
<string
name=
"account_proxy_invalid_port_range"
>
Proxy port must be between 1 and 65535 (default: 8080)
</string>
<string
name=
"account_proxy_invalid_port"
>
Proxy port must be a number (default: 8080)
</string>
<string
name=
"account_proxy_password"
>
Proxy password
</string>
<string
name=
"account_proxy_port"
>
Proxy port
</string>
<string
name=
"account_proxy_type"
>
Proxy type
</string>
...
...
app/src/main/res/values/preference_editor.xml
View file @
a27f770f
...
...
@@ -64,6 +64,7 @@
<string
name=
"events_message_none"
>
Don\'t notify
</string>
<string
name=
"events_show_text"
>
Show message in notification\nShow message text in notification area
</string>
<string
name=
"events_visible_chat"
>
Notify in current chat\nNotify on incoming messages in current chat
</string>
<string
name=
"events_suppress_100"
>
Suppress some status messages\nDon\'t get \'This room is not anonymous\' messages
</string>
<string
name=
"negative_priotiry_summary"
>
%s (you won\'t receive messages from any chat)
</string>
<string
name=
"preference_accounts"
>
XMPP accounts\nManage accounts
</string>
<string
name=
"preference_security"
>
Security\nSecurity settings
</string>
...
...
app/src/main/res/values/preferences.xml
View file @
a27f770f
...
...
@@ -74,6 +74,7 @@
<item>
com.xabber.android.data.extension.otr.OTRTable
</item>
<item>
com.xabber.android.data.message.chat.VibroTable
</item>
<item>
com.xabber.android.data.notification.NotificationTable
</item>
<item>
com.xabber.android.data.message.chat.Suppress100Table
</item>
<item>
com.xabber.android.data.message.phrase.PhraseTable
</item>
</string-array>
...
...
@@ -495,6 +496,9 @@
<string
name=
"chat_events_vibro_key"
>
chat_events_vibro
</string>
<string
name=
"chat_events_visible_chat_key"
>
chat_events_visible_chat
</string>
<string
name=
"chat_events_suppress_100_key"
>
chat_events_suppress_100
</string>
<bool
name=
"chat_events_suppress_100_default"
>
false
</bool>
<!-- preference_xabber -->
<string
name=
"preference_xabber_key"
>
preference_xabber
</string>
...
...
app/src/main/res/xml/account_editor_oauth.xml
View file @
a27f770f
...
...
@@ -38,6 +38,9 @@
android:key=
"@string/account_priority_key"
android:title=
"@string/account_priority"
android:singleLine=
"true"
android:numeric=
"signed"
android:inputType=
"numberSigned|phone"
android:digits=
"1234567890-"
/>
<ListPreference
android:title=
"@string/account_proxy_type"
...
...
@@ -54,6 +57,9 @@
android:key=
"@string/account_proxy_port_key"
android:title=
"@string/account_proxy_port"
android:singleLine=
"true"
android:numeric=
"integer"
android:inputType=
"number|phone"
android:digits=
"1234567890"
/>
<EditTextPreference
android:key=
"@string/account_proxy_user_key"
...
...
app/src/main/res/xml/account_editor_xmpp.xml
View file @
a27f770f
...
...
@@ -67,6 +67,9 @@
android:title=
"@string/account_port"
android:singleLine=
"true"
android:dependency=
"@string/account_custom_key"
android:numeric=
"integer"
android:inputType=
"number|phone"
android:digits=
"1234567890"
/>
<EditTextPreference
android:key=
"@string/account_resource_key"
...
...
@@ -77,6 +80,9 @@
android:key=
"@string/account_priority_key"
android:title=
"@string/account_priority"
android:singleLine=
"true"
android:numeric=
"signed"
android:inputType=
"numberSigned|phone"
android:digits=
"1234567890-"
/>
<CheckBoxPreference
android:title=
"@string/account_sasl"
...
...
@@ -109,6 +115,9 @@
android:key=
"@string/account_proxy_port_key"
android:title=
"@string/account_proxy_port"
android:singleLine=
"true"
android:numeric=
"integer"
android:inputType=
"number|phone"
android:digits=
"1234567890"
/>
<EditTextPreference
android:key=
"@string/account_proxy_user_key"
...
...
app/src/main/res/xml/preference_chat_contact.xml
View file @
a27f770f
...
...
@@ -40,4 +40,8 @@
android:key=
"@string/chat_events_visible_chat_key"
android:title=
"@string/events_visible_chat"
/>
<CheckBoxPreference
android:key=
"@string/chat_events_suppress_100_key"
android:title=
"@string/events_suppress_100"
/>
</PreferenceScreen>
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