Add Linphone for text sharing from other application
This commit is contained in:
parent
e9e349e76e
commit
9d92ef6b0b
7 changed files with 97 additions and 68 deletions
|
@ -104,6 +104,11 @@
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="text/plain" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".LinphoneActivity"
|
android:name=".LinphoneActivity"
|
||||||
|
|
|
@ -198,6 +198,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
message = (EditText) view.findViewById(R.id.message);
|
message = (EditText) view.findViewById(R.id.message);
|
||||||
|
|
||||||
|
if (getArguments().getString("messageDraft") != null)
|
||||||
|
message.setText(getArguments().getString("messageDraft"));
|
||||||
|
|
||||||
sendImage = (ImageView) view.findViewById(R.id.send_picture);
|
sendImage = (ImageView) view.findViewById(R.id.send_picture);
|
||||||
if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
|
if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
|
||||||
sendImage.setOnClickListener(new View.OnClickListener() {
|
sendImage.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -404,8 +407,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri) {
|
public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri, String message) {
|
||||||
this.sipUri = newSipUri;
|
this.sipUri = newSipUri;
|
||||||
|
this.message.setText(message);
|
||||||
initChatRoom(sipUri);
|
initChatRoom(sipUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,7 +1300,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
chatRoom.markAsRead();
|
chatRoom.markAsRead();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
||||||
holder.fileTransferAction.setText(getString(R.string.accept));
|
holder.fileTransferAction.setText(getString(R.string.accept));
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
private LinearLayout editList, topbar;
|
private LinearLayout editList, topbar;
|
||||||
private boolean isEditMode = false;
|
private boolean isEditMode = false;
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -74,7 +74,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
chatList = (ListView) view.findViewById(R.id.chatList);
|
chatList = (ListView) view.findViewById(R.id.chatList);
|
||||||
chatList.setOnItemClickListener(this);
|
chatList.setOnItemClickListener(this);
|
||||||
registerForContextMenu(chatList);
|
registerForContextMenu(chatList);
|
||||||
|
|
||||||
noChatHistory = (TextView) view.findViewById(R.id.noChatHistory);
|
noChatHistory = (TextView) view.findViewById(R.id.noChatHistory);
|
||||||
|
|
||||||
editList = (LinearLayout) view.findViewById(R.id.edit_list);
|
editList = (LinearLayout) view.findViewById(R.id.edit_list);
|
||||||
|
@ -85,10 +85,10 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
edit = (ImageView) view.findViewById(R.id.edit);
|
edit = (ImageView) view.findViewById(R.id.edit);
|
||||||
edit.setOnClickListener(this);
|
edit.setOnClickListener(this);
|
||||||
|
|
||||||
newDiscussion = (ImageView) view.findViewById(R.id.new_discussion);
|
newDiscussion = (ImageView) view.findViewById(R.id.new_discussion);
|
||||||
newDiscussion.setOnClickListener(this);
|
newDiscussion.setOnClickListener(this);
|
||||||
|
|
||||||
selectAll = (ImageView) view.findViewById(R.id.select_all);
|
selectAll = (ImageView) view.findViewById(R.id.select_all);
|
||||||
selectAll.setOnClickListener(this);
|
selectAll.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
delete = (ImageView) view.findViewById(R.id.delete);
|
delete = (ImageView) view.findViewById(R.id.delete);
|
||||||
delete.setOnClickListener(this);
|
delete.setOnClickListener(this);
|
||||||
|
|
||||||
mListener = new LinphoneCoreListenerBase() {
|
mListener = new LinphoneCoreListenerBase() {
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
|
@ -163,7 +163,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideAndDisplayMessageIfNoChat() {
|
private void hideAndDisplayMessageIfNoChat() {
|
||||||
if (mConversations.size() == 0) {
|
if (mConversations.size() == 0) {
|
||||||
noChatHistory.setVisibility(View.VISIBLE);
|
noChatHistory.setVisibility(View.VISIBLE);
|
||||||
|
@ -177,7 +177,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
edit.setEnabled(true);
|
edit.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
mConversations = LinphoneActivity.instance().getChatList();
|
mConversations = LinphoneActivity.instance().getChatList();
|
||||||
hideAndDisplayMessageIfNoChat();
|
hideAndDisplayMessageIfNoChat();
|
||||||
|
@ -185,7 +185,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
public void displayFirstChat(){
|
public void displayFirstChat(){
|
||||||
if (mConversations != null && mConversations.size() > 0) {
|
if (mConversations != null && mConversations.size() > 0) {
|
||||||
LinphoneActivity.instance().displayChat(mConversations.get(0));
|
LinphoneActivity.instance().displayChat(mConversations.get(0), null);
|
||||||
} else {
|
} else {
|
||||||
LinphoneActivity.instance().displayEmptyFragment();
|
LinphoneActivity.instance().displayEmptyFragment();
|
||||||
}
|
}
|
||||||
|
@ -201,20 +201,20 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
} else {
|
} else {
|
||||||
backInCall.setVisibility(View.INVISIBLE);
|
backInCall.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT_LIST);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT_LIST);
|
||||||
LinphoneActivity.instance().hideTabBar(false);
|
LinphoneActivity.instance().hideTabBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(mListener);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
@ -238,7 +238,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
menu.add(0, v.getId(), 0, getString(R.string.delete));
|
menu.add(0, v.getId(), 0, getString(R.string.delete));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||||
|
@ -246,13 +246,13 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String sipUri = chatList.getAdapter().getItem(info.position).toString();
|
String sipUri = chatList.getAdapter().getItem(info.position).toString();
|
||||||
|
|
||||||
LinphoneActivity.instance().removeFromChatList(sipUri);
|
LinphoneActivity.instance().removeFromChatList(sipUri);
|
||||||
mConversations = LinphoneActivity.instance().getChatList();
|
mConversations = LinphoneActivity.instance().getChatList();
|
||||||
hideAndDisplayMessageIfNoChat();
|
hideAndDisplayMessageIfNoChat();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
@ -314,7 +314,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
enabledDeleteButton(false);
|
enabledDeleteButton(false);
|
||||||
}
|
}
|
||||||
else if (id == R.id.new_discussion) {
|
else if (id == R.id.new_discussion) {
|
||||||
LinphoneActivity.instance().displayChat(null);
|
LinphoneActivity.instance().displayChat(null, null);
|
||||||
/*String sipUri = fastNewChat.getText().toString();
|
/*String sipUri = fastNewChat.getText().toString();
|
||||||
if (sipUri.equals("")) {
|
if (sipUri.equals("")) {
|
||||||
LinphoneActivity.instance().displayContacts(true);
|
LinphoneActivity.instance().displayContacts(true);
|
||||||
|
@ -338,7 +338,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
String sipUri = chatList.getAdapter().getItem(position).toString();
|
String sipUri = chatList.getAdapter().getItem(position).toString();
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated() && !isEditMode) {
|
if (LinphoneActivity.isInstanciated() && !isEditMode) {
|
||||||
LinphoneActivity.instance().displayChat(sipUri);
|
LinphoneActivity.instance().displayChat(sipUri, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
public TextView unreadMessages;
|
public TextView unreadMessages;
|
||||||
public CheckBox select;
|
public CheckBox select;
|
||||||
public ImageView contactPicture;
|
public ImageView contactPicture;
|
||||||
|
|
||||||
public ViewHolder(View view) {
|
public ViewHolder(View view) {
|
||||||
lastMessageView = (TextView) view.findViewById(R.id.lastMessage);
|
lastMessageView = (TextView) view.findViewById(R.id.lastMessage);
|
||||||
date = (TextView) view.findViewById(R.id.date);
|
date = (TextView) view.findViewById(R.id.date);
|
||||||
|
@ -360,9 +360,9 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatListAdapter() {}
|
ChatListAdapter() {}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mConversations.size();
|
return mConversations.size();
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
View view = null;
|
View view = null;
|
||||||
ViewHolder holder = null;
|
ViewHolder holder = null;
|
||||||
String sipUri = mConversations.get(position);
|
String sipUri = mConversations.get(position);
|
||||||
|
|
||||||
if (convertView != null) {
|
if (convertView != null) {
|
||||||
view = convertView;
|
view = convertView;
|
||||||
holder = (ViewHolder) view.getTag();
|
holder = (ViewHolder) view.getTag();
|
||||||
|
@ -388,7 +388,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
holder = new ViewHolder(view);
|
holder = new ViewHolder(view);
|
||||||
view.setTag(holder);
|
view.setTag(holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress address;
|
LinphoneAddress address;
|
||||||
try {
|
try {
|
||||||
address = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
address = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
|
|
|
@ -51,32 +51,32 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private OnClickListener chatListener = new OnClickListener() {
|
private OnClickListener chatListener = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().displayChat(v.getTag().toString());
|
LinphoneActivity.instance().displayChat(v.getTag().toString(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
contact = (LinphoneContact) getArguments().getSerializable("Contact");
|
contact = (LinphoneContact) getArguments().getSerializable("Contact");
|
||||||
|
|
||||||
this.inflater = inflater;
|
this.inflater = inflater;
|
||||||
view = inflater.inflate(R.layout.contact, container, false);
|
view = inflater.inflate(R.layout.contact, container, false);
|
||||||
|
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
displayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly");
|
displayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly");
|
||||||
}
|
}
|
||||||
|
|
||||||
editContact = (ImageView) view.findViewById(R.id.editContact);
|
editContact = (ImageView) view.findViewById(R.id.editContact);
|
||||||
editContact.setOnClickListener(this);
|
editContact.setOnClickListener(this);
|
||||||
|
|
||||||
deleteContact = (ImageView) view.findViewById(R.id.deleteContact);
|
deleteContact = (ImageView) view.findViewById(R.id.deleteContact);
|
||||||
deleteContact.setOnClickListener(this);
|
deleteContact.setOnClickListener(this);
|
||||||
|
|
||||||
organization = (TextView) view.findViewById(R.id.contactOrganization);
|
organization = (TextView) view.findViewById(R.id.contactOrganization);
|
||||||
boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization);
|
boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization);
|
||||||
String org = contact.getOrganization();
|
String org = contact.getOrganization();
|
||||||
|
@ -95,12 +95,12 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeDisplayedContact(LinphoneContact newContact) {
|
public void changeDisplayedContact(LinphoneContact newContact) {
|
||||||
contact = newContact;
|
contact = newContact;
|
||||||
displayContact(inflater, view);
|
displayContact(inflater, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
private void displayContact(LayoutInflater inflater, View view) {
|
private void displayContact(LayoutInflater inflater, View view) {
|
||||||
ImageView contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
ImageView contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||||
|
@ -109,10 +109,10 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
} else {
|
} else {
|
||||||
contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView contactName = (TextView) view.findViewById(R.id.contact_name);
|
TextView contactName = (TextView) view.findViewById(R.id.contact_name);
|
||||||
contactName.setText(contact.getFullName());
|
contactName.setText(contact.getFullName());
|
||||||
|
|
||||||
TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
|
TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
|
||||||
controls.removeAllViews();
|
controls.removeAllViews();
|
||||||
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
|
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
|
||||||
|
@ -130,11 +130,11 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
label.setText(R.string.phone_number);
|
label.setText(R.string.phone_number);
|
||||||
skip |= getResources().getBoolean(R.bool.hide_contact_phone_numbers);
|
skip |= getResources().getBoolean(R.bool.hide_contact_phone_numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
|
TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
|
||||||
tv.setText(displayednumberOrAddress);
|
tv.setText(displayednumberOrAddress);
|
||||||
tv.setSelected(true);
|
tv.setSelected(true);
|
||||||
|
|
||||||
|
|
||||||
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
if (lpc != null) {
|
if (lpc != null) {
|
||||||
|
@ -146,7 +146,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
if (contactAddress != null) {
|
if (contactAddress != null) {
|
||||||
v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE);
|
v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!displayChatAddressOnly) {
|
if (!displayChatAddressOnly) {
|
||||||
v.findViewById(R.id.contact_call).setOnClickListener(dialListener);
|
v.findViewById(R.id.contact_call).setOnClickListener(dialListener);
|
||||||
if (contactAddress != null) {
|
if (contactAddress != null) {
|
||||||
|
@ -164,17 +164,17 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
} else {
|
} else {
|
||||||
v.findViewById(R.id.contact_chat).setTag(value);
|
v.findViewById(R.id.contact_chat).setTag(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||||
v.findViewById(R.id.contact_chat).setVisibility(View.GONE);
|
v.findViewById(R.id.contact_chat).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
controls.addView(v);
|
controls.addView(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -190,7 +190,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
|
||||||
if (id == R.id.editContact) {
|
if (id == R.id.editContact) {
|
||||||
LinphoneActivity.instance().editContact(contact);
|
LinphoneActivity.instance().editContact(contact);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
private TextView contactName, contactAddress, time, date;
|
private TextView contactName, contactAddress, time, date;
|
||||||
private String sipUri, displayName, pictureUri;
|
private String sipUri, displayName, pictureUri;
|
||||||
private LinphoneContact contact;
|
private LinphoneContact contact;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -54,7 +54,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
String callDate = getArguments().getString("CallDate");
|
String callDate = getArguments().getString("CallDate");
|
||||||
|
|
||||||
view = inflater.inflate(R.layout.history_detail, container, false);
|
view = inflater.inflate(R.layout.history_detail, container, false);
|
||||||
|
|
||||||
dialBack = (ImageView) view.findViewById(R.id.call);
|
dialBack = (ImageView) view.findViewById(R.id.call);
|
||||||
dialBack.setOnClickListener(this);
|
dialBack.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -64,33 +64,33 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
} else {
|
} else {
|
||||||
back.setOnClickListener(this);
|
back.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
chat = (ImageView) view.findViewById(R.id.chat);
|
chat = (ImageView) view.findViewById(R.id.chat);
|
||||||
chat.setOnClickListener(this);
|
chat.setOnClickListener(this);
|
||||||
if (getResources().getBoolean(R.bool.disable_chat))
|
if (getResources().getBoolean(R.bool.disable_chat))
|
||||||
view.findViewById(R.id.chat).setVisibility(View.GONE);
|
view.findViewById(R.id.chat).setVisibility(View.GONE);
|
||||||
|
|
||||||
addToContacts = (ImageView) view.findViewById(R.id.add_contact);
|
addToContacts = (ImageView) view.findViewById(R.id.add_contact);
|
||||||
addToContacts.setOnClickListener(this);
|
addToContacts.setOnClickListener(this);
|
||||||
|
|
||||||
goToContact = (ImageView) view.findViewById(R.id.goto_contact);
|
goToContact = (ImageView) view.findViewById(R.id.goto_contact);
|
||||||
goToContact.setOnClickListener(this);
|
goToContact.setOnClickListener(this);
|
||||||
|
|
||||||
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||||
|
|
||||||
contactName = (TextView) view.findViewById(R.id.contact_name);
|
contactName = (TextView) view.findViewById(R.id.contact_name);
|
||||||
contactAddress = (TextView) view.findViewById(R.id.contact_address);
|
contactAddress = (TextView) view.findViewById(R.id.contact_address);
|
||||||
|
|
||||||
callDirection = (ImageView) view.findViewById(R.id.direction);
|
callDirection = (ImageView) view.findViewById(R.id.direction);
|
||||||
|
|
||||||
time = (TextView) view.findViewById(R.id.time);
|
time = (TextView) view.findViewById(R.id.time);
|
||||||
date = (TextView) view.findViewById(R.id.date);
|
date = (TextView) view.findViewById(R.id.date);
|
||||||
|
|
||||||
displayHistory(status, callTime, callDate);
|
displayHistory(status, callTime, callDate);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayHistory(String status, String callTime, String callDate) {
|
private void displayHistory(String status, String callTime, String callDate) {
|
||||||
if (status.equals(getResources().getString(R.string.missed))) {
|
if (status.equals(getResources().getString(R.string.missed))) {
|
||||||
callDirection.setImageResource(R.drawable.call_missed);
|
callDirection.setImageResource(R.drawable.call_missed);
|
||||||
|
@ -99,7 +99,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
} else if (status.equals(getResources().getString(R.string.outgoing))) {
|
} else if (status.equals(getResources().getString(R.string.outgoing))) {
|
||||||
callDirection.setImageResource(R.drawable.call_outgoing);
|
callDirection.setImageResource(R.drawable.call_outgoing);
|
||||||
}
|
}
|
||||||
|
|
||||||
time.setText(callTime == null ? "" : callTime);
|
time.setText(callTime == null ? "" : callTime);
|
||||||
Long longDate = Long.parseLong(callDate);
|
Long longDate = Long.parseLong(callDate);
|
||||||
date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),longDate,getString(R.string.history_detail_date_format)));
|
date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),longDate,getString(R.string.history_detail_date_format)));
|
||||||
|
@ -130,8 +130,8 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
contactName.setText(displayName == null ? LinphoneUtils.getAddressDisplayName(sipUri) : displayName);
|
contactName.setText(displayName == null ? LinphoneUtils.getAddressDisplayName(sipUri) : displayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeDisplayedHistory(String sipUri, String displayName, String pictureUri, String status, String callTime, String callDate) {
|
public void changeDisplayedHistory(String sipUri, String displayName, String pictureUri, String status, String callTime, String callDate) {
|
||||||
if (displayName == null ) {
|
if (displayName == null ) {
|
||||||
displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
|
displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
|
||||||
}
|
}
|
||||||
|
@ -141,11 +141,11 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
this.pictureUri = pictureUri;
|
this.pictureUri = pictureUri;
|
||||||
displayHistory(status, callTime, callDate);
|
displayHistory(status, callTime, callDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_DETAIL);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_DETAIL);
|
||||||
LinphoneActivity.instance().hideTabBar(false);
|
LinphoneActivity.instance().hideTabBar(false);
|
||||||
|
@ -161,7 +161,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
} if (id == R.id.call) {
|
} if (id == R.id.call) {
|
||||||
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, displayName, pictureUri == null ? null : Uri.parse(pictureUri));
|
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, displayName, pictureUri == null ? null : Uri.parse(pictureUri));
|
||||||
} else if (id == R.id.chat) {
|
} else if (id == R.id.chat) {
|
||||||
LinphoneActivity.instance().displayChat(sipUri);
|
LinphoneActivity.instance().displayChat(sipUri, null);
|
||||||
} else if (id == R.id.add_contact) {
|
} else if (id == R.id.add_contact) {
|
||||||
String uri = sipUri;
|
String uri = sipUri;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -639,7 +639,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayChat(String sipUri) {
|
public void displayChat(String sipUri, String message) {
|
||||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -670,10 +670,11 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
||||||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT && !emptyFragment) {
|
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT && !emptyFragment) {
|
||||||
ChatFragment chatFragment = (ChatFragment) fragment2;
|
ChatFragment chatFragment = (ChatFragment) fragment2;
|
||||||
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
|
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri, message);
|
||||||
} else {
|
} else {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString("SipUri", sipUri);
|
extras.putString("SipUri", sipUri);
|
||||||
|
extras.putString("messageDraft", message);
|
||||||
if (sipUri != null && lAddress.getDisplayName() != null) {
|
if (sipUri != null && lAddress.getDisplayName() != null) {
|
||||||
extras.putString("DisplayName", displayName);
|
extras.putString("DisplayName", displayName);
|
||||||
extras.putString("PictureUri", pictureUri);
|
extras.putString("PictureUri", pictureUri);
|
||||||
|
@ -684,10 +685,11 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
||||||
} else {
|
} else {
|
||||||
if(isTablet()){
|
if(isTablet()){
|
||||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||||
displayChat(sipUri);
|
displayChat(sipUri, message);
|
||||||
} else {
|
} else {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString("SipUri", sipUri);
|
extras.putString("SipUri", sipUri);
|
||||||
|
extras.putString("messageDraft", message);
|
||||||
if (sipUri != null && lAddress.getDisplayName() != null) {
|
if (sipUri != null && lAddress.getDisplayName() != null) {
|
||||||
extras.putString("DisplayName", displayName);
|
extras.putString("DisplayName", displayName);
|
||||||
extras.putString("PictureUri", pictureUri);
|
extras.putString("PictureUri", pictureUri);
|
||||||
|
@ -1419,7 +1421,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
||||||
LinphoneService.instance().removeMessageNotification();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
String sipUri = extras.getString("ChatContactSipUri");
|
String sipUri = extras.getString("ChatContactSipUri");
|
||||||
doNotGoToCallActivity = true;
|
doNotGoToCallActivity = true;
|
||||||
displayChat(sipUri);
|
displayChat(sipUri, null);
|
||||||
} else if (extras != null && extras.getBoolean("GoToHistory", false)) {
|
} else if (extras != null && extras.getBoolean("GoToHistory", false)) {
|
||||||
doNotGoToCallActivity = true;
|
doNotGoToCallActivity = true;
|
||||||
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
|
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
|
||||||
|
|
|
@ -54,8 +54,10 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
|
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
|
||||||
if (LinphoneService.isReady()) {
|
if (LinphoneService.isReady()) {
|
||||||
onServiceReady();
|
onServiceReady(intent);
|
||||||
} else {
|
} else {
|
||||||
// start linphone as background
|
// start linphone as background
|
||||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
|
@ -64,7 +66,7 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onServiceReady() {
|
protected void onServiceReady(Intent intent) {
|
||||||
final Class<? extends Activity> classToStart;
|
final Class<? extends Activity> classToStart;
|
||||||
if (getResources().getBoolean(R.bool.show_tutorials_instead_of_app)) {
|
if (getResources().getBoolean(R.bool.show_tutorials_instead_of_app)) {
|
||||||
classToStart = TutorialLauncherActivity.class;
|
classToStart = TutorialLauncherActivity.class;
|
||||||
|
@ -74,15 +76,31 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
classToStart = LinphoneActivity.class;
|
classToStart = LinphoneActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String sharedText = null;
|
||||||
|
if (intent != null) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
String type = intent.getType();
|
||||||
|
|
||||||
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||||
|
if ("text/plain".equals(type)) {
|
||||||
|
sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We need LinphoneService to start bluetoothManager
|
// We need LinphoneService to start bluetoothManager
|
||||||
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
|
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
|
||||||
BluetoothManager.getInstance().initBluetooth();
|
BluetoothManager.getInstance().initBluetooth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String finalSharedText = sharedText;
|
||||||
mHandler.postDelayed(new Runnable() {
|
mHandler.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
startActivity(new Intent().setClass(LinphoneLauncherActivity.this, classToStart).setData(getIntent().getData()));
|
startActivity(new Intent().setClass(LinphoneLauncherActivity.this, classToStart).setData(getIntent().getData()));
|
||||||
|
if (finalSharedText != null) {
|
||||||
|
LinphoneActivity.instance().displayChat(null, finalSharedText);
|
||||||
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -100,7 +118,7 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
onServiceReady();
|
onServiceReady(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mThread = null;
|
mThread = null;
|
||||||
|
|
Loading…
Reference in a new issue