Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
9cd81b3d
Commit
9cd81b3d
authored
4 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
shortcuts: avoid concurrent conversation access, fix exception
Change-Id: I770fe134b0036883ac925e1ea3181530a7a64861
parent
88b49837
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/app/src/main/java/cx/ring/client/HomeActivity.java
+31
-14
31 additions, 14 deletions
...ndroid/app/src/main/java/cx/ring/client/HomeActivity.java
with
31 additions
and
14 deletions
ring-android/app/src/main/java/cx/ring/client/HomeActivity.java
+
31
−
14
View file @
9cd81b3d
...
...
@@ -357,8 +357,14 @@ public class HomeActivity extends AppCompatActivity implements BottomNavigationV
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
mDisposable
.
add
((
mAccountService
.
getCurrentAccountSubject
()
.
observeOn
(
Schedulers
.
computation
())
.
subscribe
(
this
::
setShareShortcuts
)));
.
observeOn
(
Schedulers
.
io
())
.
map
(
account
->
{
Collection
<
Conversation
>
conversations
=
account
.
getConversations
();
synchronized
(
conversations
)
{
return
new
ArrayList
<>(
conversations
);
}
})
.
subscribe
(
this
::
setShareShortcuts
,
e
->
Log
.
e
(
TAG
,
"Error generating conversation shortcuts"
,
e
))));
}
int
newOrientation
=
getResources
().
getConfiguration
().
orientation
;
...
...
@@ -766,30 +772,36 @@ public class HomeActivity extends AppCompatActivity implements BottomNavigationV
return
mBinding
.
accountSwitch
;
}
private
void
setShareShortcuts
(
Account
account
)
{
Collection
<
Conversation
>
conversations
=
account
.
getConversations
();
List
<
Future
<
Bitmap
>>
futureIcons
=
new
ArrayList
<>(
conversations
.
size
());
private
void
setShareShortcuts
(
Collection
<
Conversation
>
conversations
)
{
int
targetSize
=
(
int
)
(
AvatarFactory
.
SIZE_NOTIF
*
getResources
().
getDisplayMetrics
().
density
);
int
i
=
0
;
int
maxCount
=
ShortcutManagerCompat
.
getMaxShortcutCountPerActivity
(
this
);
if
(
maxCount
==
0
)
maxCount
=
4
;
List
<
Future
<
Bitmap
>>
futureIcons
=
new
ArrayList
<>(
Math
.
min
(
conversations
.
size
(),
maxCount
));
for
(
Conversation
conversation
:
conversations
)
{
CallContact
contact
=
conversation
.
getContact
();
futureIcons
.
add
(
AvatarFactory
.
getBitmapAvatar
(
this
,
contact
,
targetSize
)
.
subscribeOn
(
Schedulers
.
computation
())
.
toFuture
());
if
(++
i
==
maxCount
)
break
;
}
int
i
=
0
;
List
<
ShortcutInfoCompat
>
shortcutInfoList
=
new
ArrayList
<>(
conversations
.
size
());
List
<
ShortcutInfoCompat
>
shortcutInfoList
=
new
ArrayList
<>(
futureIcons
.
size
());
i
=
0
;
for
(
Conversation
conversation
:
conversations
)
{
CallContact
contact
=
conversation
.
getContact
();
IconCompat
icon
=
null
;
try
{
icon
=
IconCompat
.
createWithBitmap
(
futureIcons
.
get
(
i
).
get
());
}
catch
(
Exception
e
)
{
Log
.
w
(
"RingChooserService"
,
"Failed to load icon"
,
e
);
Log
.
w
(
TAG
,
"Failed to load icon"
,
e
);
}
Bundle
bundle
=
ConversationPath
.
toBundle
(
account
.
getAccountI
D
(),
contact
.
getPrimaryNumber
());
String
key
=
ConversationPath
.
toKey
(
account
.
getAccountI
D
(),
contact
.
getPrimaryNumber
());
Bundle
bundle
=
ConversationPath
.
toBundle
(
conversation
.
getAccountI
d
(),
contact
.
getPrimaryNumber
());
String
key
=
ConversationPath
.
toKey
(
conversation
.
getAccountI
d
(),
contact
.
getPrimaryNumber
());
Person
person
=
new
Person
.
Builder
()
.
setName
(
contact
.
getDisplayName
())
...
...
@@ -806,12 +818,17 @@ public class HomeActivity extends AppCompatActivity implements BottomNavigationV
.
build
();
shortcutInfoList
.
add
(
shortcutInfo
);
i
++;
if
(++
i
==
maxCount
)
break
;
}
Log
.
w
(
TAG
,
"ShortcutManagerCompat.addDynamicShortcuts "
+
shortcutInfoList
.
size
());
try
{
Log
.
d
(
TAG
,
"Adding shortcuts: "
+
shortcutInfoList
.
size
());
ShortcutManagerCompat
.
removeAllDynamicShortcuts
(
this
);
ShortcutManagerCompat
.
addDynamicShortcuts
(
this
,
shortcutInfoList
);
}
catch
(
Exception
e
)
{
Log
.
w
(
TAG
,
"Error adding shortcuts"
,
e
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment