Added option to chosse whether the contact shortcut sends to last chatroom or contact details
This commit is contained in:
parent
8d5e5f0c8f
commit
396609102d
7 changed files with 90 additions and 20 deletions
|
@ -70,7 +70,9 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
unexpectedError();
|
||||
}
|
||||
if (!mProxyConfig.getDomain().equals(getString(R.string.default_domain))) {
|
||||
Log.e("[Account Linking] Can't link account on domain " + mProxyConfig.getDomain());
|
||||
Log.e(
|
||||
"[Account Linking] Can't link account on domain "
|
||||
+ mProxyConfig.getDomain());
|
||||
unexpectedError();
|
||||
}
|
||||
mAccountCreator.setUsername(identity.getUsername());
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.content.pm.ShortcutInfo;
|
|||
import android.content.pm.ShortcutManager;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.Address;
|
||||
|
@ -70,8 +71,22 @@ class ApiTwentyFivePlus {
|
|||
ContactsManager.getInstance().findContactFromAddress(participantAddress);
|
||||
|
||||
if (contact != null && !contacts.contains(contact)) {
|
||||
if (context.getResources().getBoolean(R.bool.shortcut_to_contact)) {
|
||||
ShortcutInfo shortcut = manager.createContactShortcutInfo(contact);
|
||||
if (shortcut != null) {
|
||||
Log.i(
|
||||
"[Shortcut] Creating launcher shortcut "
|
||||
+ shortcut.getShortLabel()
|
||||
+ " for contact "
|
||||
+ shortcut.getShortLabel());
|
||||
shortcuts.add(shortcut);
|
||||
contacts.add(contact);
|
||||
i += 1;
|
||||
}
|
||||
} else if (context.getResources().getBoolean(R.bool.shortcut_to_chatroom)) {
|
||||
String peerAddress = room.getPeerAddress().asStringUriOnly();
|
||||
ShortcutInfo shortcut = manager.createChatRoomShortcutInfo(contact, peerAddress);
|
||||
ShortcutInfo shortcut =
|
||||
manager.createChatRoomShortcutInfo(contact, peerAddress);
|
||||
if (shortcut != null) {
|
||||
Log.i(
|
||||
"[Shortcut] Creating launcher shortcut "
|
||||
|
@ -84,6 +99,7 @@ class ApiTwentyFivePlus {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shortcutManager.setDynamicShortcuts(shortcuts);
|
||||
manager.destroy();
|
||||
|
|
|
@ -138,14 +138,19 @@ public class ContactsActivity extends MainActivity {
|
|||
showContactsList();
|
||||
}
|
||||
|
||||
if (extras.containsKey("ContactUri")) {
|
||||
if (extras.containsKey("ContactUri") || extras.containsKey("ContactId")) {
|
||||
String contactId = extras.getString("ContactId");
|
||||
if (contactId == null) {
|
||||
String uri = extras.getString("ContactUri");
|
||||
Log.i("[Contacts Activity] Found ContactUri " + uri);
|
||||
Log.i("[Contacts Activity] Found Contact URI " + uri);
|
||||
Uri contactUri = Uri.parse(uri);
|
||||
String id = ContactsManager.getInstance().getAndroidContactIdFromUri(contactUri);
|
||||
contactId = ContactsManager.getInstance().getAndroidContactIdFromUri(contactUri);
|
||||
} else {
|
||||
Log.i("[Contacts Activity] Found Contact ID " + contactId);
|
||||
}
|
||||
|
||||
LinphoneContact linphoneContact =
|
||||
ContactsManager.getInstance().findContactFromAndroidId(id);
|
||||
ContactsManager.getInstance().findContactFromAndroidId(contactId);
|
||||
if (linphoneContact != null) {
|
||||
showContactDetails(linphoneContact);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,15 @@ public class LinphoneContact extends AndroidContact
|
|||
return contact;
|
||||
}
|
||||
|
||||
public String getContactId() {
|
||||
if (isAndroidContact()) {
|
||||
return getAndroidId();
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LinphoneContact contact) {
|
||||
String fullName = getFullName() != null ? getFullName() : "";
|
||||
|
|
|
@ -82,7 +82,7 @@ public class ContactSettingsFragment extends SettingsFragment {
|
|||
}
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API25_NOUGAT_71)
|
||||
&& getResources().getBoolean(R.bool.create_most_recent_chat_rooms_shortcuts)) {
|
||||
&& getResources().getBoolean(R.bool.create_shortcuts)) {
|
||||
mCreateShortcuts.setChecked(mPrefs.shortcutsCreationEnabled());
|
||||
} else {
|
||||
mCreateShortcuts.setVisibility(View.GONE);
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.util.ArraySet;
|
|||
import java.util.Set;
|
||||
import org.linphone.R;
|
||||
import org.linphone.chat.ChatActivity;
|
||||
import org.linphone.contacts.ContactsActivity;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
|
@ -79,4 +80,36 @@ public class LinphoneShortcutManager {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShortcutInfo createContactShortcutInfo(LinphoneContact contact) {
|
||||
if (contact == null) return null;
|
||||
|
||||
Bitmap bm = null;
|
||||
if (contact.getThumbnailUri() != null) {
|
||||
bm = ImageUtils.getRoundBitmapFromUri(mContext, contact.getThumbnailUri());
|
||||
}
|
||||
Icon icon =
|
||||
bm == null
|
||||
? Icon.createWithResource(mContext, R.drawable.avatar)
|
||||
: Icon.createWithBitmap(bm);
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setClass(mContext, ContactsActivity.class);
|
||||
intent.addFlags(
|
||||
Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
intent.putExtra("ContactId", contact.getContactId());
|
||||
|
||||
return new ShortcutInfo.Builder(mContext, contact.getContactId())
|
||||
.setShortLabel(contact.getFullName())
|
||||
.setIcon(icon)
|
||||
.setCategories(mCategories)
|
||||
.setIntent(intent)
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
Log.e("[Shortcuts Manager] ShortcutInfo.Builder exception: " + e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,9 +93,14 @@
|
|||
<bool name="send_multiple_images_as_different_messages">true</bool>
|
||||
<bool name="use_big_pictures_to_preview_images_file_transfers">true</bool>
|
||||
<bool name="show_sip_uri_in_chat">false</bool>
|
||||
<bool name="create_most_recent_chat_rooms_shortcuts">true</bool>
|
||||
<bool name="force_end_to_end_encryption_in_chat">false</bool>
|
||||
|
||||
<!-- Shortcuts -->
|
||||
<bool name="create_shortcuts">true</bool>
|
||||
<!-- The below two settings are mutually exclusive -->
|
||||
<bool name="shortcut_to_contact">true</bool>
|
||||
<bool name="shortcut_to_chatroom">false</bool>
|
||||
|
||||
<!-- Contacts -->
|
||||
<bool name="hide_contact_phone_numbers">false</bool>
|
||||
<bool name="hide_contact_sip_addresses">false</bool>
|
||||
|
|
Loading…
Reference in a new issue