Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-android
Commits
64f70d4d
Commit
64f70d4d
authored
Mar 14, 2021
by
Adrien Béraud
Committed by
Sébastien Blin
Jun 11, 2021
Browse files
ConversationPath: factor logic
Change-Id: Ic910a890558efaa1d93e608ad9e08e50152dcd6c
parent
cdcbbbb0
Changes
12
Hide whitespace changes
Inline
Side-by-side
ring-android/app/src/main/java/cx/ring/fragments/ConversationFragment.java
View file @
64f70d4d
...
...
@@ -126,8 +126,6 @@ public class ConversationFragment extends BaseSupportFragment<ConversationPresen
public
static
final
int
REQ_ADD_CONTACT
=
42
;
public
static
final
String
KEY_CONTACT_RING_ID
=
BuildConfig
.
APPLICATION_ID
+
".CONTACT_RING_ID"
;
public
static
final
String
KEY_ACCOUNT_ID
=
BuildConfig
.
APPLICATION_ID
+
".ACCOUNT_ID"
;
public
static
final
String
KEY_PREFERENCE_PENDING_MESSAGE
=
"pendingMessage"
;
public
static
final
String
KEY_PREFERENCE_CONVERSATION_COLOR
=
"color"
;
public
static
final
String
KEY_PREFERENCE_CONVERSATION_LAST_READ
=
"lastRead"
;
...
...
ring-android/app/src/main/java/cx/ring/fragments/ShareWithFragment.java
View file @
64f70d4d
...
...
@@ -145,8 +145,7 @@ public class ShareWithFragment extends Fragment {
if
(
type
!=
null
&&
type
.
startsWith
(
"text/"
))
{
intent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
previewText
.
getText
().
toString
());
}
intent
.
putExtra
(
ConversationFragment
.
KEY_ACCOUNT_ID
,
smartListViewModel
.
getAccountId
());
intent
.
putExtra
(
ConversationFragment
.
KEY_CONTACT_RING_ID
,
smartListViewModel
.
getUri
().
getUri
());
intent
.
putExtras
(
ConversationPath
.
toBundle
(
smartListViewModel
.
getAccountId
(),
smartListViewModel
.
getUri
()));
intent
.
setClass
(
requireActivity
(),
ConversationActivity
.
class
);
startActivity
(
intent
);
}
...
...
ring-android/app/src/main/java/cx/ring/fragments/SmartListFragment.java
View file @
64f70d4d
...
...
@@ -426,7 +426,7 @@ public class SmartListFragment extends BaseSupportFragment<SmartListPresenter> i
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
HomeActivity
.
REQUEST_CODE_QR_CONVERSATION
&&
data
!=
null
&&
resultCode
==
Activity
.
RESULT_OK
)
{
String
contactId
=
data
.
getStringExtra
(
Conversation
Fragment
.
KEY_CONTACT_RING_ID
);
String
contactId
=
data
.
getStringExtra
(
Conversation
Path
.
KEY_CONVERSATION_URI
);
if
(
contactId
!=
null
)
{
presenter
.
startConversation
(
net
.
jami
.
model
.
Uri
.
fromString
(
contactId
));
}
...
...
ring-android/app/src/main/java/cx/ring/tv/call/TVCallActivity.java
View file @
64f70d4d
...
...
@@ -22,7 +22,6 @@ import android.content.Intent;
import
android.media.AudioManager
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.WindowManager
;
...
...
@@ -34,8 +33,11 @@ import androidx.fragment.app.FragmentTransaction;
import
cx.ring.R
;
import
cx.ring.application.JamiApplication
;
import
net.jami.call.CallView
;
import
cx.ring.fragments.ConversationFragment
;
import
cx.ring.utils.ConversationPath
;
import
net.jami.services.NotificationService
;
import
net.jami.utils.Log
;
...
...
@@ -59,7 +61,7 @@ public class TVCallActivity extends FragmentActivity {
setTurnScreenOn
(
true
);
setShowWhenLocked
(
true
);
}
else
{
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_SHOW_WHEN_LOCKED
|
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_SHOW_WHEN_LOCKED
|
WindowManager
.
LayoutParams
.
FLAG_TURN_SCREEN_ON
);
}
setContentView
(
R
.
layout
.
tv_activity_call
);
...
...
@@ -69,19 +71,18 @@ public class TVCallActivity extends FragmentActivity {
JamiApplication
.
getInstance
().
getInjectionComponent
().
inject
(
this
);
JamiApplication
.
getInstance
().
startDaemon
();
boolean
audioOnly
=
false
;
String
accountId
=
getIntent
().
getStringExtra
(
ConversationFragment
.
KEY_ACCOUNT_ID
);
String
ringId
=
getIntent
().
getStringExtra
(
ConversationFragment
.
KEY_CONTACT_RING_ID
);
ConversationPath
path
=
ConversationPath
.
fromIntent
(
intent
);
FragmentManager
fragmentManager
=
getSupportFragmentManager
();
FragmentTransaction
fragmentTransaction
=
fragmentManager
.
beginTransaction
();
if
(!
TextUtils
.
isEmpty
(
ringId
))
{
Log
.
d
(
TAG
,
"onCreate: outgoing call"
);
callFragment
=
TVCallFragment
.
newInstance
(
TVCallFragment
.
ACTION_PLACE_CALL
,
accountId
,
ringId
,
audioOnly
);
if
(
path
!=
null
)
{
Log
.
d
(
TAG
,
"onCreate: outgoing call "
+
path
);
callFragment
=
TVCallFragment
.
newInstance
(
intent
.
getAction
(),
path
.
getAccountId
(),
path
.
getConversationId
(),
intent
.
getExtras
().
getString
(
Intent
.
EXTRA_PHONE_NUMBER
,
path
.
getConversationId
()),
false
);
fragmentTransaction
.
replace
(
R
.
id
.
main_call_layout
,
callFragment
,
CALL_FRAGMENT_TAG
).
commit
();
}
else
{
Log
.
d
(
TAG
,
"onCreate: incoming call"
);
...
...
@@ -89,14 +90,13 @@ public class TVCallActivity extends FragmentActivity {
String
confId
=
getIntent
().
getStringExtra
(
NotificationService
.
KEY_CALL_ID
);
Log
.
d
(
TAG
,
"onCreate: conf "
+
confId
);
callFragment
=
TVCallFragment
.
newInstance
(
TVCallFragm
ent
.
ACTION_
GET_CALL
,
confId
);
callFragment
=
TVCallFragment
.
newInstance
(
Int
ent
.
ACTION_
VIEW
,
confId
);
fragmentTransaction
.
replace
(
R
.
id
.
main_call_layout
,
callFragment
,
CALL_FRAGMENT_TAG
).
commit
();
}
}
@Override
public
void
onUserLeaveHint
()
{
public
void
onUserLeaveHint
()
{
Fragment
fragment
=
getSupportFragmentManager
().
findFragmentByTag
(
CALL_FRAGMENT_TAG
);
if
(
fragment
instanceof
CallView
)
{
CallView
callFragment
=
(
CallView
)
fragment
;
...
...
ring-android/app/src/main/java/cx/ring/tv/call/TVCallFragment.java
View file @
64f70d4d
...
...
@@ -100,13 +100,8 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
public
static
final
String
TAG
=
TVCallFragment
.
class
.
getSimpleName
();
public
static
final
String
ACTION_PLACE_CALL
=
"PLACE_CALL"
;
public
static
final
String
ACTION_GET_CALL
=
"GET_CALL"
;
public
static
final
String
KEY_ACTION
=
"action"
;
public
static
final
String
KEY_ACCOUNT_ID
=
"accountId"
;
public
static
final
String
KEY_CONF_ID
=
"confId"
;
public
static
final
String
KEY_CONTACT_RING_ID
=
"CONTACT_RING_ID"
;
public
static
final
String
KEY_AUDIO_ONLY
=
"AUDIO_ONLY"
;
private
static
final
int
REQUEST_CODE_ADD_PARTICIPANT
=
6
;
...
...
@@ -137,15 +132,15 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
@Inject
DeviceRuntimeService
mDeviceRuntimeService
;
public
static
TVCallFragment
newInstance
(
@NonNull
String
action
,
@Null
able
String
accountI
D
,
@N
ullable
String
contact
RingId
,
boolean
audioOnly
)
{
public
static
TVCallFragment
newInstance
(
@NonNull
String
action
,
@N
onN
ull
String
accountI
d
,
@N
onNull
String
conversationId
,
@NonNull
String
contact
Uri
,
boolean
audioOnly
)
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
KEY_ACTION
,
action
);
bundle
.
put
String
(
KEY_ACCOUNT_ID
,
accountID
);
bundle
.
putS
e
ri
alizable
(
KEY_CONTACT_RING_ID
,
contact
RingId
);
bundle
.
put
All
(
ConversationPath
.
toBundle
(
accountId
,
conversationId
)
);
bundle
.
putS
t
ri
ng
(
Intent
.
EXTRA_PHONE_NUMBER
,
contact
Uri
);
bundle
.
putBoolean
(
KEY_AUDIO_ONLY
,
audioOnly
);
TVCallFragment
countDownF
ragment
=
new
TVCallFragment
();
countDownF
ragment
.
setArguments
(
bundle
);
return
countDownF
ragment
;
TVCallFragment
f
ragment
=
new
TVCallFragment
();
f
ragment
.
setArguments
(
bundle
);
return
f
ragment
;
}
public
static
TVCallFragment
newInstance
(
@NonNull
String
action
,
@Nullable
String
confId
)
{
...
...
@@ -168,9 +163,9 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
super
.
initPresenter
(
presenter
);
String
action
=
getArguments
().
getString
(
KEY_ACTION
);
if
(
action
!=
null
)
{
if
(
action
.
equals
(
ACTION
_PLACE
_CALL
))
{
if
(
action
.
equals
(
Intent
.
ACTION_CALL
))
{
prepareCall
(
false
);
}
else
if
(
action
.
equals
(
ACTION_GET_CALL
))
{
}
else
if
(
action
.
equals
(
Intent
.
ACTION_VIEW
))
{
presenter
.
initIncomingCall
(
getArguments
().
getString
(
KEY_CONF_ID
),
true
);
}
}
...
...
@@ -451,15 +446,13 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement
PopupMenu
popup
=
new
PopupMenu
(
context
,
view
);
popup
.
inflate
(
R
.
menu
.
conference_participant_actions
);
popup
.
setOnMenuItemClickListener
(
item
->
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
conv_contact_details
:
presenter
.
openParticipantContact
(
call
);
break
;
case
R
.
id
.
conv_contact_hangup
:
presenter
.
hangupParticipant
(
call
);
break
;
default
:
return
false
;
int
itemId
=
item
.
getItemId
();
if
(
itemId
==
R
.
id
.
conv_contact_details
)
{
presenter
.
openParticipantContact
(
call
);
}
else
if
(
itemId
==
R
.
id
.
conv_contact_hangup
)
{
presenter
.
hangupParticipant
(
call
);
}
else
{
return
false
;
}
return
true
;
});
...
...
ring-android/app/src/main/java/cx/ring/tv/contact/TVContactFragment.java
View file @
64f70d4d
...
...
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
cx.ring.tv.contact
;
...
...
@@ -46,6 +45,9 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import
cx.ring.R
;
import
cx.ring.application.JamiApplication
;
import
cx.ring.client.CallActivity
;
import
cx.ring.client.HomeActivity
;
import
cx.ring.fragments.CallFragment
;
import
cx.ring.fragments.ConversationFragment
;
import
net.jami.model.Uri
;
import
net.jami.services.NotificationService
;
...
...
@@ -195,20 +197,17 @@ public class TVContactFragment extends BaseDetailFragment<TVContactPresenter> im
}
@Override
public
void
callContact
(
String
accountID
,
Uri
uri
)
{
Context
context
=
requireContext
();
Intent
intent
=
new
Intent
(
context
,
TVCallActivity
.
class
);
intent
.
putExtra
(
ConversationFragment
.
KEY_ACCOUNT_ID
,
accountID
);
intent
.
putExtra
(
ConversationFragment
.
KEY_CONTACT_RING_ID
,
uri
.
getRawUriString
());
context
.
startActivity
(
intent
,
null
);
public
void
callContact
(
String
accountId
,
Uri
conversationUri
,
Uri
uri
)
{
startActivity
(
new
Intent
(
Intent
.
ACTION_CALL
)
.
setClass
(
requireContext
(),
TVCallActivity
.
class
)
.
putExtras
(
ConversationPath
.
toBundle
(
accountId
,
conversationUri
))
.
putExtra
(
Intent
.
EXTRA_PHONE_NUMBER
,
uri
.
getUri
()));
}
@Override
public
void
goToCallActivity
(
String
id
)
{
Context
context
=
requireContext
();
Intent
intent
=
new
Intent
(
context
,
TVCallActivity
.
class
);
intent
.
putExtra
(
NotificationService
.
KEY_CALL_ID
,
id
);
context
.
startActivity
(
intent
,
null
);
startActivity
(
new
Intent
(
requireContext
(),
TVCallActivity
.
class
)
.
putExtra
(
NotificationService
.
KEY_CALL_ID
,
id
));
}
@Override
...
...
ring-android/app/src/main/java/cx/ring/tv/contact/TVContactPresenter.java
View file @
64f70d4d
...
...
@@ -77,14 +77,19 @@ public class TVContactPresenter extends RootPresenter<TVContactView> {
public
void
contactClicked
()
{
Account
account
=
mAccountService
.
getAccount
(
mAccountId
);
if
(
account
!=
null
)
{
Conference
conf
=
account
.
getByUri
(
mUri
).
getCurrentCall
();
Conversation
conversation
=
account
.
getByUri
(
mUri
);
Conference
conf
=
conversation
.
getCurrentCall
();
if
(
conf
!=
null
&&
!
conf
.
getParticipants
().
isEmpty
()
&&
conf
.
getParticipants
().
get
(
0
).
getCallStatus
()
!=
Call
.
CallStatus
.
INACTIVE
&&
conf
.
getParticipants
().
get
(
0
).
getCallStatus
()
!=
Call
.
CallStatus
.
FAILURE
)
{
getView
().
goToCallActivity
(
conf
.
getId
());
}
else
{
getView
().
callContact
(
mAccountId
,
mUri
);
if
(
conversation
.
isSwarm
())
{
getView
().
callContact
(
mAccountId
,
mUri
,
conversation
.
getContact
().
getUri
());
}
else
{
getView
().
callContact
(
mAccountId
,
mUri
,
mUri
);
}
}
}
}
...
...
ring-android/app/src/main/java/cx/ring/tv/contact/TVContactView.java
View file @
64f70d4d
...
...
@@ -27,7 +27,7 @@ import net.jami.smartlist.SmartListViewModel;
public
interface
TVContactView
extends
BaseView
{
void
showContact
(
SmartListViewModel
model
);
void
callContact
(
String
accountID
,
Uri
uri
);
void
callContact
(
String
accountID
,
Uri
conversationUri
,
Uri
uri
);
void
goToCallActivity
(
String
id
);
...
...
ring-android/app/src/main/java/cx/ring/tv/conversation/TvConversationAdapter.java
View file @
64f70d4d
...
...
@@ -365,7 +365,7 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi
private
void
configureForFileInfoTextMessage
(
@NonNull
final
TvConversationViewHolder
viewHolder
,
@NonNull
final
Interaction
interaction
,
int
position
)
{
DataTransfer
file
=
(
DataTransfer
)
interaction
;
File
path
=
presenter
.
getDeviceRuntimeService
().
getConversationPath
(
file
.
getConversationId
(),
file
.
getStoragePath
());
File
path
=
presenter
.
getDeviceRuntimeService
().
getConversationPath
(
interaction
.
getConversationId
()
==
null
?
interaction
.
getConversation
().
getParticipant
()
:
interaction
.
getConversationId
(),
file
.
getStoragePath
());
file
.
setSize
(
path
.
length
());
String
timeString
=
timestampToDetailString
(
viewHolder
.
itemView
.
getContext
(),
file
.
getTimestamp
());
...
...
ring-android/app/src/main/java/cx/ring/tv/main/MainFragment.java
View file @
64f70d4d
...
...
@@ -14,8 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
cx.ring.tv.main
;
...
...
@@ -362,9 +361,7 @@ public class MainFragment extends BaseBrowseFragment<MainPresenter> implements M
@Override
public
void
callContact
(
String
accountID
,
String
number
)
{
Intent
intent
=
new
Intent
(
getActivity
(),
TVCallActivity
.
class
);
intent
.
putExtra
(
ConversationFragment
.
KEY_ACCOUNT_ID
,
accountID
);
intent
.
putExtra
(
ConversationFragment
.
KEY_CONTACT_RING_ID
,
number
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_CALL
,
ConversationPath
.
toUri
(
accountID
,
number
),
getActivity
(),
TVCallActivity
.
class
);
startActivity
(
intent
,
null
);
}
...
...
ring-android/app/src/main/java/cx/ring/tv/search/ContactSearchFragment.java
View file @
64f70d4d
...
...
@@ -14,8 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
cx.ring.tv.search
;
...
...
@@ -36,7 +35,6 @@ import android.view.View;
import
cx.ring.R
;
import
cx.ring.application.JamiApplication
;
import
cx.ring.client.CallActivity
;
import
cx.ring.fragments.ConversationFragment
;
import
net.jami.model.Contact
;
import
net.jami.smartlist.SmartListViewModel
;
import
cx.ring.tv.call.TVCallActivity
;
...
...
@@ -138,7 +136,6 @@ public class ContactSearchFragment extends BaseSearchFragment<ContactSearchPrese
@Override
public
void
startCall
(
String
accountID
,
String
number
)
{
Intent
intent
=
new
Intent
(
CallActivity
.
ACTION_CALL
,
ConversationPath
.
toUri
(
accountID
,
number
),
getActivity
(),
TVCallActivity
.
class
);
intent
.
putExtra
(
ConversationFragment
.
KEY_ACCOUNT_ID
,
accountID
);
intent
.
putExtra
(
Intent
.
EXTRA_PHONE_NUMBER
,
number
);
startActivity
(
intent
);
getActivity
().
finish
();
...
...
ring-android/app/src/main/java/cx/ring/utils/ConversationPath.java
View file @
64f70d4d
/*
* Copyright (C) 2004-2021 Savoir-faire Linux Inc.
*
* Authors: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
cx.ring.utils
;
import
android.content.Intent
;
...
...
@@ -8,17 +26,21 @@ import android.text.TextUtils;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Objects
;
import
cx.ring.fragments.ConversationFragment
;
import
net.jami.model.Conversation
;
import
net.jami.model.Interaction
;
import
net.jami.utils.StringUtils
;
import
net.jami.utils.Tuple
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Objects
;
import
cx.ring.BuildConfig
;
public
class
ConversationPath
{
public
static
final
String
KEY_CONVERSATION_URI
=
BuildConfig
.
APPLICATION_ID
+
".conversationUri"
;
public
static
final
String
KEY_ACCOUNT_ID
=
BuildConfig
.
APPLICATION_ID
+
".accountId"
;
private
final
String
accountId
;
private
final
String
conversationId
;
public
ConversationPath
(
String
account
,
String
contact
)
{
...
...
@@ -84,14 +106,14 @@ public class ConversationPath {
return
toBundle
(
accountId
,
conversationId
);
}
public
void
toBundle
(
Bundle
bundle
)
{
bundle
.
putString
(
ConversationFragment
.
KEY_CONTACT_RING_ID
,
conversationId
);
bundle
.
putString
(
ConversationFragment
.
KEY_ACCOUNT_ID
,
accountId
);
bundle
.
putString
(
KEY_CONVERSATION_URI
,
conversationId
);
bundle
.
putString
(
KEY_ACCOUNT_ID
,
accountId
);
}
public
static
Bundle
toBundle
(
String
accountId
,
String
uri
)
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
ConversationFragment
.
KEY_CONTACT_RING_ID
,
uri
);
bundle
.
putString
(
ConversationFragment
.
KEY_ACCOUNT_ID
,
accountId
);
bundle
.
putString
(
KEY_CONVERSATION_URI
,
uri
);
bundle
.
putString
(
KEY_ACCOUNT_ID
,
accountId
);
return
bundle
;
}
public
static
Bundle
toBundle
(
String
accountId
,
net
.
jami
.
model
.
Uri
uri
)
{
...
...
@@ -135,8 +157,8 @@ public class ConversationPath {
public
static
ConversationPath
fromBundle
(
@Nullable
Bundle
bundle
)
{
if
(
bundle
!=
null
)
{
String
accountId
=
bundle
.
getString
(
ConversationFragment
.
KEY_ACCOUNT_ID
);
String
contactId
=
bundle
.
getString
(
ConversationFragment
.
KEY_CONTACT_RING_ID
);
String
accountId
=
bundle
.
getString
(
KEY_ACCOUNT_ID
);
String
contactId
=
bundle
.
getString
(
KEY_CONVERSATION_URI
);
if
(
accountId
!=
null
&&
contactId
!=
null
)
{
return
new
ConversationPath
(
accountId
,
contactId
);
}
...
...
Write
Preview
Supports
Markdown
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