Improved UI when using external sharing mode to choose the chat room to use + added toast for contact picking as well
This commit is contained in:
parent
44d8f49b86
commit
51e9d1507e
5 changed files with 50 additions and 124 deletions
|
@ -700,34 +700,6 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
|
||||
}
|
||||
|
||||
private void displayChat(
|
||||
String localSipUri,
|
||||
String remoteSipUri,
|
||||
String message,
|
||||
String fileUri,
|
||||
String pictureUri,
|
||||
String thumbnailUri,
|
||||
String displayName,
|
||||
Address lAddress) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("LocalSipUri", localSipUri);
|
||||
extras.putString("RemoteSipUri", remoteSipUri);
|
||||
|
||||
if (message != null) extras.putString("messageDraft", message);
|
||||
if (fileUri != null) extras.putString("fileSharedUri", fileUri);
|
||||
if (remoteSipUri != null && lAddress.getDisplayName() != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
extras.putString("ThumbnailUri", thumbnailUri);
|
||||
}
|
||||
|
||||
if (remoteSipUri == null) {
|
||||
changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras);
|
||||
} else {
|
||||
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
|
||||
}
|
||||
}
|
||||
|
||||
public void goToChatCreator(
|
||||
String address,
|
||||
ArrayList<ContactAddress> selectedContacts,
|
||||
|
@ -837,70 +809,6 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||
}
|
||||
|
||||
public void displayChat(
|
||||
String localSipUri, String remoteSipUri, String message, String fileUri) {
|
||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String pictureUri = null;
|
||||
String thumbnailUri = null;
|
||||
String displayName = null;
|
||||
|
||||
Address lAddress = null;
|
||||
if (remoteSipUri != null) {
|
||||
lAddress = LinphoneManager.getLc().interpretUrl(remoteSipUri);
|
||||
if (lAddress == null) return;
|
||||
LinphoneContact contact =
|
||||
ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
displayName = contact != null ? contact.getFullName() : null;
|
||||
|
||||
if (contact != null && contact.getPhotoUri() != null) {
|
||||
pictureUri = contact.getPhotoUri().toString();
|
||||
thumbnailUri = contact.getThumbnailUri().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (mCurrentFragment == FragmentsAvailable.CHAT_LIST
|
||||
|| mCurrentFragment == FragmentsAvailable.GROUP_CHAT) {
|
||||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
if (fragment2 != null
|
||||
&& fragment2.isVisible()
|
||||
&& mCurrentFragment == FragmentsAvailable.GROUP_CHAT
|
||||
&& !mEmptyFragment) {
|
||||
ChatMessagesFragment chatFragment = (ChatMessagesFragment) fragment2;
|
||||
chatFragment.changeDisplayedChat(localSipUri, remoteSipUri);
|
||||
} else {
|
||||
displayChat(
|
||||
localSipUri,
|
||||
remoteSipUri,
|
||||
message,
|
||||
fileUri,
|
||||
pictureUri,
|
||||
thumbnailUri,
|
||||
displayName,
|
||||
lAddress);
|
||||
}
|
||||
} else {
|
||||
if (isTablet()) {
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||
} else {
|
||||
displayChat(
|
||||
localSipUri,
|
||||
remoteSipUri,
|
||||
message,
|
||||
fileUri,
|
||||
pictureUri,
|
||||
thumbnailUri,
|
||||
displayName,
|
||||
lAddress);
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneManager.getInstance().updateUnreadCountForChatRoom(localSipUri, remoteSipUri, 0);
|
||||
displayMissedChats(LinphoneManager.getInstance().getUnreadMessageCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
@ -1122,12 +1030,6 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
}
|
||||
|
||||
public void setAddresGoToDialerAndCall(String number, String name) {
|
||||
// Bundle extras = new Bundle();
|
||||
// extras.putString("SipUri", number);
|
||||
// extras.putString("DisplayName", name);
|
||||
// extras.putString("Photo", photo == null ? null : photo.toString());
|
||||
// changeCurrentFragment(FragmentsAvailable.DIALER, extras);
|
||||
|
||||
AddressType address = new AddressText(this, null);
|
||||
address.setText(number);
|
||||
address.setDisplayedName(name);
|
||||
|
@ -1407,13 +1309,12 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
protected void onStart() {
|
||||
super.onStart();
|
||||
ArrayList<String> permissionsList = new ArrayList<>();
|
||||
permissionsList.add(
|
||||
Manifest.permission
|
||||
.SYSTEM_ALERT_WINDOW); // This one is to allow floating notifications
|
||||
permissionsList.add(
|
||||
"android.permission.FOREGROUND_SERVICE"); // Manifest.permission.FOREGROUND_SERVICE,
|
||||
// This one is to allow floating notifications
|
||||
permissionsList.add(Manifest.permission.SYSTEM_ALERT_WINDOW);
|
||||
// Manifest.permission.FOREGROUND_SERVICE,
|
||||
// required starting Android 9 to be able
|
||||
// to start a foreground service
|
||||
permissionsList.add("android.permission.FOREGROUND_SERVICE");
|
||||
|
||||
int contacts =
|
||||
getPackageManager()
|
||||
|
@ -1557,13 +1458,16 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
Intent intent = getIntent();
|
||||
|
||||
if (intent.getStringExtra("msgShared") != null) {
|
||||
displayChat(null, null, intent.getStringExtra("msgShared"), null);
|
||||
intent.putExtra("msgShared", "");
|
||||
}
|
||||
if (intent.getStringExtra("fileShared") != null
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("messageDraft", intent.getStringExtra("msgShared"));
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, extras);
|
||||
intent.removeExtra("msgShared");
|
||||
} else if (intent.getStringExtra("fileShared") != null
|
||||
&& !intent.getStringExtra("fileShared").equals("")) {
|
||||
displayChat(null, null, null, intent.getStringExtra("fileShared"));
|
||||
intent.putExtra("fileShared", "");
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("fileSharedUri", intent.getStringExtra("fileShared"));
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, extras);
|
||||
intent.removeExtra("fileShared");
|
||||
}
|
||||
mIsOnBackground = false;
|
||||
|
||||
|
|
|
@ -168,17 +168,6 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
mAddressToCall = null;
|
||||
}
|
||||
startActivity(newIntent);
|
||||
if (classToStart == LinphoneActivity.class
|
||||
&& LinphoneActivity.isInstanciated()
|
||||
&& (stringFileShared != null || fileUri != null)) {
|
||||
if (stringFileShared != null) {
|
||||
LinphoneActivity.instance()
|
||||
.displayChat(null, null, stringFileShared, null);
|
||||
} else if (fileUri != null) {
|
||||
LinphoneActivity.instance()
|
||||
.displayChat(null, null, null, stringUriFileShared);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
1000);
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -115,8 +116,10 @@ public class ChatRoomsFragment extends Fragment
|
|||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle extras = (Bundle) getArguments().clone();
|
||||
getArguments().clear();
|
||||
LinphoneActivity.instance()
|
||||
.goToChatCreator(null, null, null, false, null, false, false);
|
||||
.goToChatCreator(null, null, null, false, extras, false, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -124,8 +127,10 @@ public class ChatRoomsFragment extends Fragment
|
|||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle extras = (Bundle) getArguments().clone();
|
||||
getArguments().clear();
|
||||
LinphoneActivity.instance()
|
||||
.goToChatCreator(null, null, null, false, null, true, false);
|
||||
.goToChatCreator(null, null, null, false, extras, true, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -173,6 +178,19 @@ public class ChatRoomsFragment extends Fragment
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (getArguments() != null) {
|
||||
String fileSharedUri = getArguments().getString("fileSharedUri");
|
||||
String messageSharedUri = getArguments().getString("messageDraft");
|
||||
if (fileSharedUri != null || messageSharedUri != null) {
|
||||
Toast.makeText(
|
||||
LinphoneActivity.instance(),
|
||||
R.string.toast_choose_chat_room_for_sharing,
|
||||
Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -182,11 +200,13 @@ public class ChatRoomsFragment extends Fragment
|
|||
mChatRoomsAdapter.toggleSelection(position);
|
||||
} else {
|
||||
ChatRoom room = (ChatRoom) mChatRoomsAdapter.getItem(position);
|
||||
Bundle extras = (Bundle) getArguments().clone();
|
||||
getArguments().clear();
|
||||
LinphoneActivity.instance()
|
||||
.goToChat(
|
||||
room.getLocalAddress().asStringUriOnly(),
|
||||
room.getPeerAddress().asString(),
|
||||
null);
|
||||
extras);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.widget.ImageView;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -75,9 +76,19 @@ public class ContactsFragment extends Fragment
|
|||
if (getArguments() != null) {
|
||||
mEditOnClick = getArguments().getBoolean("EditOnClick");
|
||||
mSipAddressToAdd = getArguments().getString("SipAddress");
|
||||
if (getArguments().getString("DisplayName") != null)
|
||||
if (getArguments().getString("DisplayName") != null) {
|
||||
mDisplayName = getArguments().getString("DisplayName");
|
||||
}
|
||||
mOnlyDisplayChatAddress = getArguments().getBoolean("ChatAddressOnly");
|
||||
|
||||
if (getArguments().getBoolean("EditOnClick")) {
|
||||
Toast.makeText(
|
||||
LinphoneActivity.instance(),
|
||||
R.string.toast_choose_contact_for_edition,
|
||||
Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
getArguments().clear();
|
||||
}
|
||||
|
||||
mNoSipContact = view.findViewById(R.id.noSipContact);
|
||||
|
|
|
@ -178,6 +178,7 @@
|
|||
<string name="contact_organization">Organization</string>
|
||||
<string name="invite_friend">Invite</string>
|
||||
<string name="invite_friend_text">Hello, join me on Linphone! You can download it for free at http://www.linphone.org/technical-corner/linphone/downloads</string>
|
||||
<string name="toast_choose_contact_for_edition">Select the contact to edit or create a new one</string>
|
||||
|
||||
<!-- Chat -->
|
||||
<string name="no_chat_history">No conversations</string>
|
||||
|
@ -244,6 +245,7 @@
|
|||
<string name="participant_max_count_exceeded">Max participant count exceeded by %s</string>
|
||||
<string name="unexpected_event">Unexpected event %i for %s</string>
|
||||
<string name="download_file">Download</string>
|
||||
<string name="toast_choose_chat_room_for_sharing">Select the conversation in which to send your selection or create a new one</string>
|
||||
|
||||
<!-- Status Bar -->
|
||||
<string name="status_connected">Registered</string>
|
||||
|
|
Loading…
Reference in a new issue